0
$\begingroup$

I was told by a class mate that the smallest exponent that we can represent by a single-precision floating-point number (which uses 8 bits for the exponent) is $-126$ and the greatest is $127$.

I know that exponents are represented using excess or bias notation, that is, we represent all exponents, including the negative ones, using positive binary numbers, which we obtain by summing to the real exponent (which can be negative) the bias. In the single-precision floating-point system, the bias is $2^{\text{# of bits in exponent - 1}} - 1$, which in our case is $2^{8 - 1} - 1 = 2^7 - 1 = 128 - 1 = 127$.

To obtain the decimal exponent from the biased one, we can subtract $-127$.

Now, since $0$ has a special representation in this system, the first biased exponent is $1$, so $1 - 127 = -126$.

But I don't understand why the greatest exponent isn't $128$, since, again, the first biased exponent would be $1$.

What am I missing?

$\endgroup$
3
$\begingroup$

Exponent $-127$ is reserved for representing zero and denormal numbers, and the exponent $+128$ is reserved for representing infinities and NaNs, as described here: https://en.wikipedia.org/wiki/Single-precision_floating-point_format#Exponent_encoding

So for normalized numbers, the exponent range is $[-126,127]$.

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy