-0
is not less than 0
or +0
, both -0 < 0
and -0 < +0
returns False
, you’re mixing the behavior of Math.min
with the comparison of -0
with 0
/+0
.
The specification of Math.min
is clear on this point:
b. If number is -0𝔽 and lowest is +0𝔽, set lowest to -0𝔽.
Without this exception, the behavior of Math.min
and Math.max
would depend on the order of arguments, which can be considered an odd behavior — you probably want Math.min(x, y)
to always equal Math.min(y, x)
— so that might be one possible justification.
Note: This exception was already present in the 1997 specification for Math.min(x, y)
, so that’s not something that was added later on.