Skip to content

NaN with math.min/max functions? #3387

@jetibest

Description

@jetibest

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions