What is a subnormal floating point number?

BЈовић picture BЈовић · Dec 1, 2011 · Viewed 24.7k times · Source

isnormal() reference page tells :

Determines if the given floating point number arg is normal, i.e. is neither zero, subnormal, infinite, nor NaN.

A number being zero, infinite or NaN is clear what it means. But it also says subnormal. When is a number subnormal?

Answer

Kerrek SB picture Kerrek SB · Dec 1, 2011

In the IEEE754 standard, floating point numbers are represented as binary scientific notation, x = M × 2e. Here M is the mantissa and e is the exponent. Mathematically, you can always choose the exponent so that 1 ≤ M < 2.* However, since in the computer representation the exponent can only have a finite range, there are some numbers which are bigger than zero, but smaller than 1.0 × 2emin. Those numbers are the subnormals or denormals.

Practically, the mantissa is stored without the leading 1, since there is always a leading 1, except for subnormal numbers (and zero). Thus the interpretation is that if the exponent is non-minimal, there is an implicit leading 1, and if the exponent is minimal, there isn't, and the number is subnormal.

*) More generally, 1 ≤ M < B  for any base-B scientific notation.