[docs] Incorrect description of != involving NaN operands

Robert Gamble rgamble99 at gmail.com
Tue Sep 3 09:46:38 EDT 2019


In 6.10.1. Value comparisons
<https://docs.python.org/3/reference/expressions.html#value-comparisons>,
the following paragraph appears (emphasis mine):

The not-a-number values float('NaN') and decimal.Decimal('NaN') are
special. Any ordered comparison of a number to a not-a-number value is
false. A counter-intuitive implication is that *not-a-number values are not
equal to themselves*. For example, if x = float('NaN'), 3 < x, x < 3, x ==x
, *x != x* are all false. This behavior is compliant with IEEE 754.

The underlined portion is correct but the the part about *x != x* being
false (which conflicts with the underlined portion) is incorrect.  NaN !=
NaN evaluates to *True*, both in Python 2 and 3 and under IEEE 754.

-- 
Thanks,

Robert Gamble
http://www.robertgamble.net/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/docs/attachments/20190903/447c08f0/attachment.html>


More information about the docs mailing list