Why 8-bit signed binary numbers go from -127 to 128

binarycomputational mathematicscomputer sciencediscrete mathematicsnumerical methods

I'm studying floating point representation using "Numerical Mathematics and Computing 6ed." By Cheney and Kincaid.

This paragraphs, which can be found in page 46, puzzle me:

enter image description here

I know that $m$ is stored in computer's memory roughly as "_ _ _ _ _ _ _ _" where the leftmost slot is reserved for the sign of the number, leaving 7 slots for the number itself. Thus, $11111111_2=-127_{10}$ is the lowest possible value $m$ can attain, while $01111111_2=127_{10}$ is the highest; why, then, the book mentions that $128$ is the highest possible value for $m$?

Thanks in advance.

Best Answer

This is a convention, but a good one.

In floating point representation that you are studying, $8$ bits are reserved for the exponent $m$, which (obviously) can represent $256$ different values. It makes a lot of sense to pick a contiguous range of exponents, e.g. $0$ to $255$, or $-256$ to $-1$, or $-128$ to $127$, or (what was eventually picked as a standard) $-127$ to $128$.

Now, notice that the exponent will be used to power the number $2$. This means that the actual numbers represented will be in the range of (roughly) $2^{-127}$ to (roughly) $2^{128}$. This is a well-chosen range that can capture very small and also very large numbers. If one of the other, more asymmetric, choices was adopted instead, we would either compromise on not being able to represent very small numbers - or very large numbers.

The fact the chosen range is precisely $-127$ to $128$ probably has something to do with the fact that the mantissa ($q$) represents a number between $(0.1)_2=(0.5)_{10}$ and $1$, so the actual floating point number you eventually get is actually between (roughly) $2^{-128}$ and $2^{128}$, which is as symmetric as you can get!