Describe the bug
Passing a unit with value NaN is currently not handled well by the min() and max() functions (and potentially others?).
The function is currently not symmetrical when one argument is a unit with value NaN, that is, max(a, b) is not equal to max(b, a).
With regular numbers (not instances of unit) the functions work as expected.
To Reproduce
math.max(NaN, 123) is NaN
math.max(123, NaN) is NaN
math.max(math.unit(NaN, 's'), math.unit(123, 's')).value is NaN
math.max(math.unit(123, 's'), math.unit(NaN, 's')).value is 123 <-- expected NaN instead of 123 here
Tested in Developer Console (F12) on https://mathjs.org/docs/reference/functions.html
Describe the bug
Passing a unit with value
NaNis currently not handled well by themin()andmax()functions (and potentially others?).The function is currently not symmetrical when one argument is a unit with value NaN, that is,
max(a, b)is not equal tomax(b, a).With regular numbers (not instances of unit) the functions work as expected.
To Reproduce
math.max(NaN, 123)isNaNmath.max(123, NaN)isNaNmath.max(math.unit(NaN, 's'), math.unit(123, 's')).valueisNaNmath.max(math.unit(123, 's'), math.unit(NaN, 's')).valueis123<-- expectedNaNinstead of123hereTested in Developer Console (F12) on https://mathjs.org/docs/reference/functions.html