Binary and addition
Why 8 Bits Max Out at 255, Not 256
8 bits have 256 different states, but the first state is 0, so the last one is 255. This page uses the unsigned, non-negative whole-number model used in this project.
Each extra bit doubles the states
One bit has two states, 0 and 1. Each extra bit lets every existing state end in 0 or 1, doubling the count, so n bits have 2 to the power n states.
| Bits | Number of states | Maximum |
|---|---|---|
| 1 | 2 | 1 |
| 2 | 4 | 3 |
| 4 | 16 | 15 |
| 8 | 256 | 255 |
Counting starts at 0
All zeros is a state too, and it means 0. So 256 states cover 0 to 255, and the maximum is 2 to the power n minus 1. Nothing is lost; 0 simply takes one of the states.
Where 255 comes from, and why 256 needs nine bits
11111111₂ is 128+64+32+16+8+4+2+1, which is exactly 255.
Add 1 and you get 100000000₂, which is 256 and needs a ninth bit.
| Bits n | Number of states 2ⁿ | Maximum 2ⁿ − 1 |
|---|---|---|
| 1 | 2 | 1 |
| 2 | 4 | 3 |
| 4 | 16 | 15 |
| 8 | 256 | 255 |
255 + 255 = 510
11111111₂ + 11111111₂ = 111111110₂
Adding two 8-bit numbers can give nine bits
Each input is between 0 and 255, so the sum can reach 510. Bit Kido's 8-bit calculator keeps the ninth bit instead of cutting the result down to 8 bits.
This page covers unsigned, non-negative whole numbers only. It doesn't cover signed two's complement or every meaning 8-bit data can have, and real hardware may be designed differently.
Check yourself
How many states do 4 bits have, and what is the maximum?
Answer
2×2×2×2=16 states. Counting from 0, the maximum is 15, written 1111₂.
How many bits do you need at least to show 256?
Answer
Nine. 256 is written 100000000₂, and 8 bits only reach 255.
Can 255+255 be kept in just 8 bits?
Answer
Not in this project's model. The result 510 is written 111111110₂ and needs nine bits, so the calculator keeps the top carry.