Skip to content

Commit 810f68f

Browse files
authored
Fix misinformation about NaN != NaN comparison (GH-19357)
1 parent 909f4a3 commit 810f68f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Doc/reference/expressions.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,8 +1422,9 @@ built-in types.
14221422
The not-a-number values ``float('NaN')`` and ``decimal.Decimal('NaN')`` are
14231423
special. Any ordered comparison of a number to a not-a-number value is false.
14241424
A counter-intuitive implication is that not-a-number values are not equal to
1425-
themselves. For example, if ``x = float('NaN')``, ``3 < x``, ``x < 3``, ``x
1426-
== x``, ``x != x`` are all false. This behavior is compliant with IEEE 754.
1425+
themselves. For example, if ``x = float('NaN')``, ``3 < x``, ``x < 3`` and
1426+
``x == x`` are all false, while ``x != x`` is true. This behavior is
1427+
compliant with IEEE 754.
14271428

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

0 commit comments

Comments
 (0)