math.issubnormal(x) returns True if x is a subnormal (denormalized) floating-point number: finite, nonzero, and smaller in magnitude than sys.float_info.min (2**-1022).
Subnormal numbers allow gradual underflow down to 5e-324 at reduced precision. Note that 0.0, normal floats, infinities, and NaN all return False.
math.issubnormal() is a function in Python's standard math module: import it with import math and call math.issubnormal(...), or import the name directly with from math import issubnormal. New in recent Python versions (3.15 at the time of writing; check your version with import sys; print(sys.version)).
Syntax
Import math (check hasattr(math, "issubnormal") for compatibility).
python
import math
sub = math.issubnormal(x)
Call
What it does
math.issubnormal(1e-310)
Returns True.
math.issubnormal(5e-324)
Returns True (smallest positive subnormal).
math.issubnormal(0.0)
Returns False (zero is not subnormal).
math.issubnormal(1.0)
Returns False (normal float).
Portable fallback for older Python releases: x != 0.0 and math.isfinite(x) and abs(x) < sys.float_info.min.
Example 1 — Check Subnormal Numbers, Zero, and Normal Floats Portably
Use hasattr(math, "issubnormal") with a sys.float_info.min fallback across test values.
python
import math
import sys
def is_subnormal(x):
if hasattr(math, "issubnormal"):
return math.issubnormal(x)
return x != 0.0 and math.isfinite(x) and abs(x) < sys.float_info.min
for v in [1e-310, -5e-324, 0.0, 1.0, math.inf]:
print(f"{v!r:>8} -> {is_subnormal(v)}")
Zero shift stays normal. Exactly at sys.float_info.min, normal is True and subnormal is False.
Crossing into denormals. Halving by even one binary exponent drops precision into subnormals.
Mutually exclusive flags. Every nonzero finite float is either normal or subnormal, never both.
Example 3 — Detect math.issubnormal() Availability at Runtime
Run math.issubnormal() when present or fall back cleanly on older versions.
python
import math
import sys
vals = [2.0 ** -1023, 2.0 ** -1022, 0.0]
if hasattr(math, "issubnormal"):
print("math.issubnormal:", [math.issubnormal(x) for x in vals])
else:
res = [
x != 0.0 and math.isfinite(x) and abs(x) < sys.float_info.min
for x in vals
]
print("fallback:", res)
Output
# On a Python version that has math.issubnormal:
math.issubnormal: [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
Clean threshold split.2**-1023 is subnormal (True) while 2**-1022 is normal (False).
Same output on both branches. Older versions reproduce exact IEEE 754 subnormal classification.
Zero safely rejected. Third item 0.0 returns False.
Frequently Asked Questions
It is new in recent Python versions (3.15 at the time of writing); check import sys; print(sys.version) or hasattr(math, "issubnormal").
No. 0.0 and -0.0 are zeros, not subnormal numbers, so math.issubnormal(0.0) returns False.
A very small nonzero finite float below sys.float_info.min (2**-1022) that trades leading precision bits to represent values down to 5e-324.
Use x != 0.0 and math.isfinite(x) and abs(x) < sys.float_info.min.
In tight numerical loops, subnormal arithmetic can be slower or lose relative precision when values approach underflow.