diff --git a/Doc/library/decimal.rst b/Doc/library/decimal.rst index a24f2ff52af7c4..1b022212d1f655 100644 --- a/Doc/library/decimal.rst +++ b/Doc/library/decimal.rst @@ -1728,6 +1728,8 @@ condition. 0 ** 0 x ** (non-integer) x ** Infinity + NaN >= 0 + NaN < 0 .. class:: Overflow @@ -1857,6 +1859,8 @@ expanding the precision sufficiently to avoid loss of significance: Decimal('0.0060000') +.. _decimal-notes-specials: + Special values ^^^^^^^^^^^^^^ diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst index d66682d33c616d..9618e7394f4cbc 100644 --- a/Doc/reference/expressions.rst +++ b/Doc/reference/expressions.rst @@ -1894,12 +1894,15 @@ built-in types. involved, they compare mathematically (algorithmically) correct without loss of precision. - The not-a-number values ``float('NaN')`` and ``decimal.Decimal('NaN')`` are + The not-a-number floating-point numbers, like ``float('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`` and ``x == x`` are all false, while ``x != x`` is true. This behavior is - compliant with IEEE 754. + compliant with IEEE 754. Similar behavior holds for + :class:`decimal.Decimal`'s not-a-number values, like ``Decimal('NaN')``. + Refer to the :ref:`Special values ` section + of the :mod:`decimal` documentation. * ``None`` and :data:`NotImplemented` are singletons. :PEP:`8` advises that comparisons for singletons should always be done with ``is`` or ``is not``,