measurement.js icon indicating copy to clipboard operation
measurement.js copied to clipboard

Undefined and Null handling

Open Philzen opened this issue 11 years ago • 0 comments

Null values are not handled correctly, e.g.

measurement('Speed').convert(null).from('km/h').to('m/s');       // = 0
measurement('Speed').convert(undefined).from('km/h').to('m/s');  // = NaN
measurement('Temperature').convert(null).from('c').to('k');      // = 273.15
measurement('Temperature').convert(null).from('f').to('c');      // = -17.77777777777778
measurement('Temperature').convert(undefined).from('c').to('k'); // = NaN

Internally any conversion operations must be avoided if value is null or undefined and it should just be returned again.

Philzen avatar Apr 23 '14 13:04 Philzen