Lesson Objective
- Be able to add together up to three binary numbers.
- Apply binary shifts to multiply and divide numbers.
KS3, GCSE, A-Level Computing Resources
Work right to left:
Here are examples of Base 10 numbers:
1 | 1 | ||||||
1 | 5 | 2 | 6 | ||||
+ | 1 | 7 | + | 1 | 9 | ||
3 | 2 | 4 | 5 |
Work right to left and apply these simple rules:
Here are examples of two 8 bit numbers being added together:
1 | 1 | 1 | |||||||
0 | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 14 | |
+ | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 162 |
1 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 176 |
...
1 | 1 | 1 | 1 | ||||||
0 | 1 | 0 | 0 | 0 | 1 | 1 | 1 | 71 | |
+ | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 1 | 79 |
1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 150 |
When and extra bit is created to represent a number.
Here is an example of an overflow error:
1 | 1 | 1 | 1 | 1 | |||||
1 | 1 | 0 | 0 | 1 | 1 | 0 | 0 | 204 | |
+ | 1 | 0 | 0 | 1 | 1 | 1 | 0 | 1 | 157 |
1 | 0 | 1 | 1 | 0 | 1 | 0 | 0 | 1 | 361 |
Method 1.
Add the first two, then add the third to the result.
We will carry out the addition 1011 + 0111 + 101
We can can see the 1011 (11) + 0111 (7) + 101 (5) = 23
1 | 1 | 1 | 1 | ||||
1 | 0 | 1 | 1 | 11 | |||
+ | 0 | 1 | 1 | 1 | 7 | ||
1 | 0 | 0 | 1 | 0 | |||
+ | 1 | 0 | 1 | 5 | |||
1 | 0 | 1 | 1 | 1 | 23 |
Method 2.
Left Shift = Multiply. Each shift is the number multiplied by a power of 2
0 Shift | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | Original |
1 Shift | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | *2 |
2 Shift | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | *4 |
3 Shift | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | *8 |
Right Shift = Divide. Each shift is the number division by a power of 2
0 Shift | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | Original |
1 Shift | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | /2 |
2 Shift | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | /4 |
3 Shift | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | /8 |