To add binary numbers, add column by column from the right, writing a digit and carrying when a column reaches 2 or more. If a carry leaves the left-most column of a fixed-size number, the result has overflowed: it needs more bits than are available.
This lesson uses the binary place values you already know and links to bit depth, which explains why a fixed number of bits has a limit.
What are the addition rules?
| Column sum | Write | Carry |
|---|---|---|
| 0 | 0 | 0 |
| 1 | 1 | 0 |
| 2 (1 + 1) | 0 | 1 |
| 3 (1 + 1 + carry 1) | 1 | 1 |
Each column adds the two bits and the carry from the column on the right. The carry is the one thing people forget, so write it in a small row above the numbers.
Worked example without overflow
Add 01101011 and 00111001 (8 bits).
First, convert so you can check later: 01101011 = 64 + 32 + 8 + 2 + 1 = 107, and 00111001 = 32 + 16 + 8 + 1 = 57. Expected sum: 164.
Now add from the right (column 0 is the right-most):
| Column | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|
| Carry in | 1 | 1 | 1 | 1 | 0 | 1 | 1 | 0 |
| First number | 0 | 1 | 1 | 0 | 1 | 0 | 1 | 1 |
| Second number | 0 | 0 | 1 | 1 | 1 | 0 | 0 | 1 |
| Result | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 0 |
Column 0: 1 + 1 = 10, write 0 carry 1. Column 1: 1 + 0 + 1 = 10, write 0 carry 1. Column 2: 0 + 0 + 1 = 1.
Column 3: 1 + 1 = 10, write 0 carry 1. Column 4: 0 + 1 + 1 = 10, write 0 carry 1. Column 5: 1 + 1 + 1 = 11, write 1 carry 1.
Column 6: 1 + 0 + 1 = 10, write 0 carry 1. Column 7: 0 + 0 + 1 = 1, no carry out.
The result is 10100100. Check: 128 + 32 + 4 = 164. It matches, and no carry left column 7, so there is no overflow.
Worked example with overflow
Add 11001000 and 01000110 (8 bits). In denary that is 200 + 70 = 270, which is more than 255, so overflow is expected.
| Column | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|
| Carry in | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| First number | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 |
| Second number | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 |
| Result | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 0 |
Column 6: 1 + 1 = 10, write 0 carry 1. Column 7: 1 + 0 + 1 = 10, write 0 and carry 1 out of the left-most column.
An 8-bit register keeps only 00001110, which is 14. The true answer needs nine bits: 1 00001110 = 256 + 14 = 270. So the correct statement is: the result overflows because 270 is too large for 8 bits (maximum 255), and the stored value 14 is wrong.
The mistake to watch for
A common slip is writing the digit but forgetting to carry.
Question: Add 00000111 and 00000001.
Mistaken working: column 0: 1 + 1 = 0, but the carry is not written, so columns 1 and 2 are copied down. The answer reads 00000110.
That answer is 6, yet 7 + 1 must be 8. The correction is to write the carry row first and tick each carry off when you use it.
Column 0 gives 0 carry 1, column 1 gives 1 + 0 + 1 = 0 carry 1, column 2 gives 1 + 0 + 1 = 0 carry 1, and column 3 gives 0 + 0 + 1 = 1. The correct answer is 00001000. If the denary value looks wrong when you convert back, a carry was lost.
Check yourself
1. Add 00011011 and 00000101.
Show answer
27 + 5 = 32. Column by column: carries ripple from column 0 to column 4, and the result is 00100000. Check: 32.
2. Add 10000001 and 10000001. Does it overflow?
Show answer
129 + 129 = 258, which is more than 255. Column 0: 1 + 1 = 0 carry 1. Column 7: 1 + 1 = 0 carry 1 out. The stored result is 00000010 with a carry out, so yes, it overflows. The stored 2 is wrong because the true answer is 258.
3. Does 180 + 76 overflow in 8 bits?
Show answer
180 + 76 = 256, which is one more than the maximum 255. Yes, it overflows: the stored 8 bits would be 00000000.
Where this leads next
Continue with explaining character encoding and then bit depth, which explains the limit behind overflow. Practise all of it in the mixed practice set.
Many students can add correctly but then struggle to explain overflow in words for the mark. A teacher can practise that wording with you in online one-to-one Computer Science tuition.