Skip to content

bpo-47031: Improve documentation for math.nan #32170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions Doc/library/math.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down