Why is $\mathbf{realmax}$ equal to $\mathbf{(2-eps)*2^{1023}}$?

357 Views Asked by At

In Numerical Computing With Matlab it is stated that(Under the IEEE standard): "the smallest positive normalized floating-point number has f = 0 and e = −1022. The largest floating-point number has f a little less than 1 and e = 1023."

We have realmin = $2^{-1022}$ and realmax = $(2-eps)*2^{1023}$

where eps = $2^{-52}$

My question is why does the computation for realmax involve an extra $(2-eps)$ term and not realmin? Realmax ends up being approximately equal to $2^{1024}$ but this value is larger than $2^{1023}$ thus violating the maximum allotted number of bits for the exponent. (11 bits for exponent in IEEE)

You can see realmin is $2^{-1022}$ and not any value lower is allowed. Why is this not the case for realmax?

1

There are 1 best solutions below

7
On BEST ANSWER

The 64 bit double-precision floating point format has 1 sign bit, 11 bits for the exponent, and 52 bits for the fractional part of the significand.

The exponent 11111111111 (eleven ones, in binary) is used for special purposes (inf & nan), so the largest exponent available for numbers is 11111111110, which is 2046 in decimal, but there's an offset of 1023 that one must subtract, so it really represents $2046-1023=1023$.

And the largest fraction is 1111111111111111111111111111111111111111111111111111 (fifty-two ones), which has an implicit “1.” in front, so that it means the binary number 1.1111111111111111111111111111111111111111111111111111, or $2-2^{-52}=2-\varepsilon$ in other words (not quite “two”, just as close as you can get).

So $$ \mathrm{realmax} = (2-\varepsilon) \times 2^{1023} . $$

Similarly, the exponent 00000000000 is used for special purposes (zero & subnormal numbers), so the smallest exponent available for normalized numbers is 00000000001, which after subtracting the offset becomes $1-1023=-1022$.

And the smallest fraction is 0000000000000000000000000000000000000000000000000000, which corresponds to the number 1.0000000000000000000000000000000000000000000000000000 (so just “one”, no $\varepsilon$ here).

Therefore $$ \mathrm{realmin} = 1 \times 2^{-1022} . $$