Is this an expected behaviour or is there something wrong?
>>> min((float("nan"), 5))
nan
>>> min((5, float("nan")))
5
>>> max((5, float("nan")))
5
>>> max((float("nan"), 5))
nan
I understand that NaN
is an undefined number, and that an undefined number can be less than or greater than 5. So is it sane that the result of a built-in function depends on the order of its parameters? In my humble opinion all the function calls should return NaN.