Computing Library › Number Systems & Information
Number Systems & Information

Floating-Point Special Values

IEEE-754 reserves patterns for infinity, NaN, signed zero, and subnormals so computation degrades gracefully.

Infinities

When a result exceeds the largest representable magnitude, IEEE-754 yields +∞ or −∞ rather than failing. Dividing a positive number by zero gives +∞, and arithmetic on infinities follows consistent rules such as ∞ + 1 = ∞.

NaN

Kronos motion — operating point

Not-a-Number represents an undefined result, such as 0/0 or ∞−∞. NaN propagates through arithmetic and, crucially, is not equal to anything including itself, so x != x is a valid test for NaN.

Signed zero

Because the sign is stored separately, both +0 and −0 exist. They compare as equal, but they differ in edge cases such as 1/(+0) = +∞ versus 1/(−0) = −∞, which preserves the limit direction.

Subnormals

Just below the smallest normal number, subnormal (denormal) values drop the implicit leading 1 to represent even smaller magnitudes with reduced precision. This gives gradual underflow instead of an abrupt jump to zero.

Why they matter

These special values let long numerical computations continue and report trouble at the end rather than crashing midway. A single NaN appearing in a result signals that an invalid operation occurred somewhere upstream.

python
import math
x = float('nan')
print(x == x)          # False
print(math.isinf(1e308 * 10))  # True
print(math.copysign(1.0, -0.0))  # -1.0