mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
bpo-47031: Improve documentation for math.nan
(GH-32170)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
parent
208da6d508
commit
182e93c3f5
1 changed files with 17 additions and 2 deletions
|
@ -646,8 +646,23 @@ Constants
|
|||
|
||||
.. data:: nan
|
||||
|
||||
A floating-point "not a number" (NaN) value. Equivalent to the output of
|
||||
``float('nan')``.
|
||||
A floating-point "not a number" (NaN) value. Equivalent to the output of
|
||||
``float('nan')``. Due to the requirements of the `IEEE-754 standard
|
||||
<https://en.wikipedia.org/wiki/IEEE_754>`_, ``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 :func:`isnan` function to test
|
||||
for NaNs instead of ``is`` or ``==``.
|
||||
Example::
|
||||
|
||||
>>> import math
|
||||
>>> math.nan == math.nan
|
||||
False
|
||||
>>> float('nan') == float('nan')
|
||||
False
|
||||
>>> math.isnan(math.nan)
|
||||
True
|
||||
>>> math.isnan(float('nan'))
|
||||
True
|
||||
|
||||
.. versionchanged:: 3.11
|
||||
It is now always available.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue