PyDocs

Nav

Numeric and Mathematical Modules

nan

math

data · Added in 3.5
A floating-point “not a number” (NaN) value. Equivalent to the output of float('nan'). Due to the requirements of the IEEE-754 standard, math.nan and float('nan') are not considered to equal to any other numeric value, including themselves. To check whether a number is a NaN, use the isnan() function to test for NaNs instead of is or ==. Example:
Changed in 3.11
  • 3.11: It is now always available.
1 Example
>>> import math
>>> math.nan == math.nan
False
>>> float('nan') == float('nan')
False
>>> math.isnan(math.nan)
True
>>> math.isnan(float('nan'))
True
from the Python docs
See Also
No see-alsos for math/nan
0 Notes
No notes for nan