On this page
math.isnan
Prev: math.isinf | Up: math | Next: math.isqrt
Rel: math.acos, math.acosh, math.asin, math.asinh
Ref: docs.python.org — math.isnan
Tags: #public #python3 #stdlib #math
Import
import math
from math import isnan
Signature & Overview
math.isnan(x, /)
Return True if x is a NaN (not a number), and False otherwise.
Usage
import math
x = float("nan")
assert math.isnan(x) is True
assert (x == x) is False
Gotchas
- Never compare
x == float("nan"): NaN is not equal to anything, including itself—always usemath.isnan(x).
REPL Inspect
from math import isnan
help(isnan)
Linked from
Related notes
- tuts/python3/stdlib_module/math/isinf Linked here; links to this page; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/isqrt Linked here; links to this page; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/math/acos Linked here; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/acosh Linked here; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/asin Linked here; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/asinh Linked here; shared tags: #math, #stdlib
- tuts/c/stdlib/math shared tags: #math, #stdlib
- tuts/c/stdlib/math/fabs shared tags: #math, #stdlib
- tuts/c/stdlib/math/floor shared tags: #math, #stdlib