Python math.issubnormal() Function

Beginner
5 min read
Updated: Nov 2026
3 examples
Recent Python

Definition

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)
CallWhat 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.

Function signatures
python
math.issubnormal(x, /)
# recent Python addition (3.15 at writing); returns bool

Parameters

ParameterDescription
xRequired positional real number (int or float).

Return Value

Return ValueDescription
boolTrue if x is nonzero subnormal, else False.

Python Examples

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)}")

How It Works

  1. Inside subnormal band. Both positive 1e-310 and negative -5e-324 sit below 2**-1022 and return True.
  2. Zero excluded explicitly. Checking x != 0.0 ensures zero returns False just like native issubnormal().
  3. Normals and infinities return False. Ordinary numbers and inf stay outside the subnormal range.

Example 2 — Watch Gradual Underflow Shift Normal Floats to Subnormal

Scale down past sys.float_info.min using math.ldexp() and inspect normal vs subnormal flags.

python
import math
import sys

is_sub = getattr(
    math,
    "issubnormal",
    lambda x: x != 0.0 and math.isfinite(x) and abs(x) < sys.float_info.min,
)
is_norm = getattr(
    math,
    "isnormal",
    lambda x: math.isfinite(x) and abs(x) >= sys.float_info.min,
)

for shift in [0, -1, -10]:
    val = math.ldexp(sys.float_info.min, shift)
    norm = is_norm(val)
    sub = is_sub(val)
    print(f"shift={shift:>3} -> normal={norm}, subnormal={sub}")

How It Works

  1. Zero shift stays normal. Exactly at sys.float_info.min, normal is True and subnormal is False.
  2. Crossing into denormals. Halving by even one binary exponent drops precision into subnormals.
  3. 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)

How It Works

  1. Clean threshold split. 2**-1023 is subnormal (True) while 2**-1022 is normal (False).
  2. Same output on both branches. Older versions reproduce exact IEEE 754 subnormal classification.
  3. 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.

Next: math.lcm()

Return the least common multiple of integer arguments (Python 3.9+).

lcm() →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful