aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Flury <anthony.flury@btinternet.com>2018-09-14 18:48:50 +0100
committerBenjamin Peterson <benjamin@python.org>2018-09-14 10:48:50 -0700
commitad8a0004206ba7aec5a8a60fce413da718080db2 (patch)
treee2b36f7816a1a1bc5d7d3ee255d7ace410f68401 /Doc/reference/expressions.rst
parentbpo-34672: Don't pass NULL to gmtime_r. (GH-9312) (diff)
downloadcpython-ad8a0004206ba7aec5a8a60fce413da718080db2.tar.gz
cpython-ad8a0004206ba7aec5a8a60fce413da718080db2.tar.bz2
cpython-ad8a0004206ba7aec5a8a60fce413da718080db2.zip
closes bpo-28955: Clarified comparisons between NaN and number in reference documentation (GH-5982)
Co-authored-by: Benjamin Peterson <benjamin@python.org>
Diffstat (limited to 'Doc/reference/expressions.rst')
-rw-r--r--Doc/reference/expressions.rst11
1 files changed, 5 insertions, 6 deletions
diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst
index 33f7575a8fc..f4b16182829 100644
--- a/Doc/reference/expressions.rst
+++ b/Doc/reference/expressions.rst
@@ -1336,12 +1336,11 @@ built-in types.
involved, they compare mathematically (algorithmically) correct without loss
of precision.
- The not-a-number values :const:`float('NaN')` and :const:`Decimal('NaN')`
- are special. They are identical to themselves (``x is x`` is true) but
- are not equal to themselves (``x == x`` is false). Additionally,
- comparing any number to a not-a-number value
- will return ``False``. For example, both ``3 < float('NaN')`` and
- ``float('NaN') < 3`` will return ``False``.
+ 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.
* Binary sequences (instances of :class:`bytes` or :class:`bytearray`) can be
compared within and across their types. They compare lexicographically using