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 @@ -627,8 +627,23 @@ Constants
627
627
628
628
.. data :: nan
629
629
630
- A floating-point "not a number" (NaN) value. Equivalent to the output of
631
- ``float('nan') ``.
630
+ A floating-point "not a number" (NaN) value. Equivalent to the output of
631
+ ``float('nan') ``. Due to the requirements of the `IEEE-754 standard
632
+ <https://en.wikipedia.org/wiki/IEEE_754> `_, ``math.nan `` and ``float('nan') `` are
633
+ not considered to equal to any other numeric value, including themselves. To check
634
+ whether a number is a NaN, use the :func: `isnan ` function to test
635
+ for NaNs instead of ``is `` or ``== ``.
636
+ Example::
637
+
638
+ >>> import math
639
+ >>> math.nan == math.nan
640
+ False
641
+ >>> float('nan') == float('nan')
642
+ False
643
+ >>> math.isnan(math.nan)
644
+ True
645
+ >>> math.isnan(float('nan'))
646
+ True
632
647
633
648
.. versionadded :: 3.5
634
649
You can’t perform that action at this time.
0 commit comments