# Floating point format: why must 1−emax ≤ q+p−1 ≤ emax?

The possible finite values that can be represented in a format are determined by the base (b), the number of digits in the significand (precision, p), and the exponent (q) parameter emax:

...

q must be an integer such that 1−emax ≤ q+p−1 ≤ emax (e.g., if p=7 and emax=96 then q is −101 through 90).

I can't figure out the reasoning behind the above inequality. I would've thought (in my simplicity) that it would be -emax ≤ q ≤ emax or something similar. What am I missing?

The reason we get a larger range is denormalized numbers. Generally speaking, floating point numbers have three physical parts: sign (1 bit), mantissa $M$ and exponent $e$. Most of the time we think of the number as $\operatorname{sgn} \times 1.M \times 2^{e-e_0}$, where $e_0 = 2^{|e|}-1$ (e.g. for single precision, it's 127, since the exponent is allotted seven bits). Here "$1.M$" means the number you obtain by writing $M$ as a binary string and prefixing $1.$.

For reasons having to do with underflow (non-zero numbers turning to zero), it is important to be able to store numbers very close to zero. These numbers, named denormalized numbers or subnormalized numbers, have $e = 0$ and represent $\operatorname{sgn} \times 0.M \times 2^{1-e_0}$. (This means that normal numbers cannot have $e = 0$.) This explains the extended range mentioned in the Wikipedia page.

Other numbers having special encodings are $\pm \infty$ and NaN (not a number), which represent some illegal operation (division by zero, taking the logarithm of a non-positive number, taking the square root of a negative number, and so on). For more details, consult the Wikipedia page regarding the original standard.

• The exponent is allotted eight* bits IMO . Dec 13, 2014 at 13:11

I don't think 'subnormality' is at play here. However, 'normality' is!

The Wiki-page you refer to represents a number x to be
x = c . bq with c = 0 ... bp-1    (1)
However, the number we would want to store as an IEEE754 floating point number is represented differently:
x = c' . bq' with c' = 0 ... 1-b-p    (2)
This is the 'normalization' I referred to earlier.

We can relate (1) and (2) by reforming (1):
x = c . bq = c . b-p+1 . bp-1 . bq = c' . bp-1 . bq = c' . bq+p-1
Therefore:
q' = q+p-1      (3)

We want to store q' using a limited number range. According to the IEEE 754 standard, we'll do this using 'bias'. Let's define the bias to be emax - 1 (with emax being half the number range we have available. E.g., in the binary32 case we have 8 bits available in the exponent of a float. This leads to an emax = 0.5 . 28 = 128).
In view of this, we can write:
-emax+1 ≤ q' ≤ emax    (4)
This ensures that q' plus the bias fully covers the available (but limited) range.

Combining (3) and (4) yields the (at first sight) not so obvious equation of the wiki-page:
-emax+1 ≤ q+p-1 ≤ emax

I hope this helps!

Note: the true IEEE754 binary case also assumes the 'silent leading bit 1' which further complicates the matter and is indeed the root of subnormal numbers.

• Welcome! For future reference, you can use LaTeX to typeset mathematics, which is a good deal easier that coding up all that HTML! We have a short reference that explains the feature. Jan 5, 2016 at 20:54