c++c++11floating-pointieee-754denormal-numbers

What is a subnormal floating point number?


The isnormal() reference page says:

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

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


Solution

  • 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.