File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -646,8 +646,23 @@ Constants
646
646
647
647
.. data :: nan
648
648
649
- A floating-point "not a number" (NaN) value. Equivalent to the output of
650
- ``float('nan') ``.
649
+ A floating-point "not a number" (NaN) value. Equivalent to the output of
650
+ ``float('nan') ``. Due to the requirements of the `IEEE-754 standard
651
+ <https://en.wikipedia.org/wiki/IEEE_754> `_, ``math.nan `` and ``float('nan') `` are
652
+ not considered to equal to any other numeric value, including themselves. To check
653
+ whether a number is a NaN, use the :func: `isnan ` function to test
654
+ for NaNs instead of ``is `` or ``== ``.
655
+ Example::
656
+
657
+ >>> import math
658
+ >>> math.nan == math.nan
659
+ False
660
+ >>> float('nan') == float('nan')
661
+ False
662
+ >>> math.isnan(math.nan)
663
+ True
664
+ >>> math.isnan(float('nan'))
665
+ True
651
666
652
667
.. versionchanged :: 3.11
653
668
It is now always available.
You can’t perform that action at this time.
0 commit comments