Article
Patterns in binary numbers
Binary numbers are not random. A few patterns let you answer many questions without doing any long sums. Learn these three and you will be quicker and make fewer mistakes.
The last bit tells you odd or even
Look at the first nine numbers in binary:
| Decimal | Binary | Last bit |
|---|---|---|
| 0 | 0000 | 0 |
| 1 | 0001 | 1 |
| 2 | 0010 | 0 |
| 3 | 0011 | 1 |
| 4 | 0100 | 0 |
| 5 | 0101 | 1 |
| 6 | 0110 | 0 |
| 7 | 0111 | 1 |
| 8 | 1000 | 0 |
The last bit goes 0, 1, 0, 1, and so on. Why? Every place value except the 1s place (2, 4, 8, 16, …) is even. So only the 1s place can make a number odd. If the last bit is 1, the number is odd. If it is 0, the number is even.
Adding a zero on the right doubles the number
Compare these numbers:
| Binary | Decimal |
|---|---|
| 101 | 5 |
| 1010 | 10 |
| 10100 | 20 |
Every time we add a 0 on the right, every digit moves one place to the left. Each place is worth twice as much as the one before, so the whole number doubles. In decimal, adding a 0 on the right multiplies by 10. In binary, it multiplies by 2.
Adding a 0 on the left is different. The number 0101 is still 5, because a leading zero adds nothing.
Check your understanding
What happens to the value of a binary number when you add a 0 on its right end?
All ones: the biggest number
What is the biggest number that fits in a given number of bits? Fill every place with a 1:
| Bits | Biggest pattern | Value |
|---|---|---|
| 1 | 1 | 1 |
| 2 | 11 | 3 |
| 3 | 111 | 7 |
| 4 | 1111 | 15 |
Each biggest value is one less than the number of values that the bits can make. That is because counting starts at 0. With n bits you can make 2^n different values, and they run from 0 up to 2^n - 1.
Check your understanding
What is the biggest number that can be stored in 5 bits?
The three patterns together
The last bit
- ends in 1 means odd
- ends in 0 means even
A 0 on the right
- every digit moves one place left
- the number doubles
All ones
- n bits make 2^n values
- the biggest is 2^n - 1
- one byte tops out at 255
Worked example: one byte
A byte has 8 bits, so it can make 256 different values. They start at 0, so the biggest is 256 − 1 = 255. Check by adding all eight place values:
128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255
So 11111111 is 255, and no byte can hold a number bigger than that.
Common mistakes
- Saying the biggest value is
2^n. That is how many values there are. The biggest value is one less. - Multiplying by 10. In binary, adding a 0 on the right multiplies by 2.
- Looking at the wrong end for odd or even. The last bit (the rightmost one) decides, not the first.
- Thinking all zeros means "no number".
0000is the number 0, and it is one of the values.
On the exam
Patterns help you check an answer quickly. If a binary number ends in 1 and your decimal answer is even, you made a mistake. Also remember that a byte holds 0 to 255, not 1 to 256.
Key words
Leading zero: a 0 added at the left end. It does not change the value.
Odd and even: a binary number is odd when its last bit is 1.
Largest value: with n bits, 2^n - 1.