Does Python define the value of "NaN > 0"?

Viewed 344

Does Python defined the value of "NaN > 0"? In my Python interpreter, I get:

>>> float('nan') > 0
False

but is this guaranteed?

If I understand correctly, the IEEE 754 standard assigns False to any comparison involving NaN. However, I can't find anything in the Python documentation that indicates that this standard is followed. I even understand that 1/0 should give infinity, under IEEE 754, but Python raises an exception (ZeroDivisionError), so Python does not fully follow IEEE 754.

So, is the result of float('nan') > 0 fully defined in Python? I need to know whether it is the same on all platforms, and with all versions of Python (including old ones).

3 Answers
Related