math.isnormal(x) returns True if x is a normal floating-point number: finite, nonzero, and with magnitude at least sys.float_info.min (2**-1022, about 2.225e-308).
Zero (0.0, -0.0), tiny subnormal floats, infinities, and NaN all return False. Check the official docs for your exact Python release, and guard with hasattr(math, "isnormal") if supporting older Python.
math.isnormal() is a function in Python's standard math module: import it with import math and call math.isnormal(...), or import the name directly with from math import isnormal. New in recent Python versions (3.15 at the time of writing; check your version with import sys; print(sys.version)).
Syntax
Import math (and check hasattr for portability across Python versions).
python
import math
ok = math.isnormal(x)
Call
What it does
math.isnormal(1.0)
Returns True.
math.isnormal(0.0)
Returns False (zero is not normal).
math.isnormal(1e-310)
Returns False (subnormal float).
math.isnormal(float("inf"))
Returns False.
On Python versions without math.isnormal(), the exact IEEE 754 check is math.isfinite(x) and abs(x) >= sys.float_info.min.
Exact boundary test. At sys.float_info.min, the implicit leading IEEE 754 bit is still 1 (True).
Single bit down enters subnormal. Halving with ldexp(edge, -1) crosses into subnormal precision (False).
Portable attribute lookup.getattr uses native math.isnormal when present.
Example 3 — Detect math.isnormal() Support at Runtime
Print explicit output depending on whether your Python version provides math.isnormal().
python
import math
import sys
test_vals = [-4.5, 0.0, 1e-315]
if hasattr(math, "isnormal"):
print("math.isnormal:", [math.isnormal(v) for v in test_vals])
else:
res = [
math.isfinite(v) and abs(v) >= sys.float_info.min
for v in test_vals
]
print("fallback:", res)
Output
# On a Python version that has math.isnormal:
math.isnormal: [True, False, False]
# Fallback on older Python versions:
fallback: [True, False, False]
Lines starting with # label which branch ran; your Python interpreter prints only the matching line.
How It Works
Runtime branch. Checking hasattr(math, "isnormal") lets code opt into the native helper without crashing on older Python.
Identical boolean vector. Both branches classify -4.5 as normal and reject zero and subnormal 1e-315.
Inspect version if unsure. Run import sys; print(sys.version) to verify your interpreter release.
Frequently Asked Questions
It is new in recent Python versions (3.15 at the time of writing); run import sys; print(sys.version) or check hasattr(math, "isnormal") on your interpreter.
IEEE 754 defines zero as its own category separate from normal nonzero numbers, so zero returns False.
sys.float_info.min (2**-1022, roughly 2.2250738585072014e-308). Any nonzero number smaller than that is subnormal.
Use math.isfinite(x) and abs(x) >= sys.float_info.min.
isfinite(x) returns True for zero and subnormals, whereas isnormal(x) returns True only for nonzero normal numbers.