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

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: 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$$?

• If you represent it that way, then 0 can be represented two different ways. If you use a slightly different representation, you can represent one more number. Nov 12, 2021 at 22:08
• Remember one doesnt need to use two zeroes. $-0$ and $+0$, i.e. $10000000_2$ or $00000000_2$ rather use one extra number, so $10000000_2$ is $128_{10}$. and $00000000_2$ is $0$. then $10000001_2$ is $-1$. You can represent negative numbers however you want, its just up to you how you define them. Then there is a standard convention to use it like it was defined above.
– user366820
Nov 21, 2021 at 13:25

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!

• I'm a retired programmer, and I couldn't have explained that well. +1. Nov 12, 2021 at 22:46
• And if one uses a normalized mantissa, then $q$ represents a number $1.q_1q_2...q_{23}$ between $1$ and $2$, the doubling of the mantissa interpretation is then counteracted by shifting the exponent down by 1, which gives the standard range $-128..127$. Nov 13, 2021 at 8:11
• Since the IEEE standard is so widespread I would stress that the number system used by Kincaid and Cheney is not the IEEE standard. For the IEEE standard, the largest exponent is used to signal infinity. The smallest exponent is used to signal $0$, when the significand/mantissa is $0$ and NaN when the significand is nonzero. The smallest positive subnormal floating point number is $2^{-149}$ in IEEE single precision. The largest positive is $(2-2^{-23})*2^{127}$. For the IEEE standard, the range of exponents is not symmetrical around zero. Nov 13, 2021 at 12:22
1. Given $$n$$ bits, you can represent $$2^n$$ numbers.

2. $$2^n$$ will always be even.

3. If you ignore the bit relating to the sign and only focus on the positive integers, then you’ll get $$2^{n-1}$$ integers.

4. Starting from $$0$$, count back to $$2^{n-1}$$. This will get you to $$2^{n-1}$$, but now you don’t have $$0$$! How can we fix this?

5. Shift the negative integers over by one to fill in $$0$$. This will subtract $$1$$ from the number of negative integers.

6. An even number minus $$1$$ is odd.

7. This gives you an even number of positive integers, but an odd number of negative integers.