Adding together two binary numbers is very similar to adding two denary numbers, but remember that binary digits cannot be greater than 1.
1 + 1 = 10 (which is 2 in denary). Put 1 in the column, carry the 0.
1 + 1 + 1 = 11 (which is 3 in denary). Put 1 in the column, carry the 1.
We are going to add 00101110 and 01110111.
Step 1
Start on the right with the least-significant bit column. Add 0 and 1.
This gives us 1. Write 1 into the column.
| 0 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | |
| + | 0 | 1 | 1 | 1 | 0 | 1 | 1 | 1 |
| 1 | ||||||||
Step 2
Move left, to the 7th column. Add 1 and 1.
This gives us 10 (which is 2 in denary). Write 0 into the column and carry the 1.
| 0 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | |
| + | 0 | 1 | 1 | 1 | 0 | 1 | 1 | 1 |
| 0 | 1 | |||||||
| 1 |
Step 3
Move left, to the 6th column. Add 1 and 1.
Also add the carry bit from the previous column.
This gives us 11 (which is 3 in denary. Write 1 into the column and carry the 1.
| 0 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | |
| + | 0 | 1 | 1 | 1 | 0 | 1 | 1 | 1 |
| 1 | 0 | 1 | ||||||
| 1 | 1 |
Step 4
Move left, to the 5th column. Add 1 and 0.
Also add the carry bit from the previous column.
This gives us 10 (which is 2 in denary). Write 0 into the column and carry the 1.
| 0 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | |
| + | 0 | 1 | 1 | 1 | 0 | 1 | 1 | 1 |
| 0 | 1 | 0 | 1 | |||||
| 1 | 1 | 1 |
Step 5
Move left, to the 4th column. Add 0 and 1.
Also add the carry bit from the previous column.
This gives us 10 (which is 2 in denary). Write 0 into the column and carry the 1.
| 0 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | |
| + | 0 | 1 | 1 | 1 | 0 | 1 | 1 | 1 |
| 0 | 0 | 1 | 0 | 1 | ||||
| 1 | 1 | 1 | 1 |
Step 6
Move left, to the 3rd column. Add 1 and 1.
Also add the carry bit from the previous column.
This gives us 11 (which is 3 in denary. Write 1 into the column and carry the 1.
| 0 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | |
| + | 0 | 1 | 1 | 1 | 0 | 1 | 1 | 1 |
| 1 | 0 | 0 | 1 | 0 | 1 | |||
| 1 | 1 | 1 | 1 | 1 |
Step 7
Move left, to the 2nd column. Add 0 and 1.
Also add the carry bit from the previous column.
This gives us 10 (which is 2 in denary). Write 0 into the column and carry the 1.
| 0 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | |
| + | 0 | 1 | 1 | 1 | 0 | 1 | 1 | 1 |
| 0 | 1 | 0 | 0 | 1 | 0 | 1 | ||
| 1 | 1 | 1 | 1 | 1 | 1 |
Step 8
Move left, to the 1st column. Add 0 and 0.
Also add the carry bit from the previous column.
This gives us 1. Write 1 into the column.
| 0 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | |
| + | 0 | 1 | 1 | 1 | 0 | 1 | 1 | 1 |
| 1 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | |
| 1 | 1 | 1 | 1 | 1 | 1 |
The answer
00101110 + 01110111 = 10100101
This is equivalent to 46 + 119 = 165
Overflow Errors
An overflow error happens when a computer tries to store a number that is too large to fit in the available number of bits.
For example, when adding two 8-bit numbers, we end up with a 9th bit.
When this happens, the extra value is lost or wraps around, leading to an incorrect result.
| 1 | 1 | 1 | 1 | 0 | 0 | 1 | 1 | |
| + | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
| 1 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 1 |
| 1 |