Skip to content

Commit

Permalink
Fix misinformation about NaN != NaN comparison (pythonGH-19357)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdickinson authored Apr 5, 2020
1 parent 909f4a3 commit 810f68f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Doc/reference/expressions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1422,8 +1422,9 @@ built-in types.
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.
themselves. For example, if ``x = float('NaN')``, ``3 < x``, ``x < 3`` and
``x == x`` are all false, while ``x != x`` is true. This behavior is
compliant with IEEE 754.

* ``None`` and ``NotImplemented`` are singletons. :PEP:`8` advises that
comparisons for singletons should always be done with ``is`` or ``is not``,
Expand Down

0 comments on commit 810f68f

Please sign in to comment.