Skip to content
IGCSE·Tuition
Computer Science · Lessons

Add binary values with overflow awareness

Binary addition looks like ordinary addition, until a column holds three ones and the carry goes missing.

On this page
  1. What are the addition rules?
  2. Worked example without overflow
  3. Worked example with overflow
  4. The mistake to watch for
  5. Check yourself
  6. Where this leads next

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 sumWriteCarry
000
110
2 (1 + 1)01
3 (1 + 1 + carry 1)11

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):

Column76543210
Carry in11110110
First number01101011
Second number00111001
Result10100100

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.

Column76543210
Carry in10000000
First number11001000
Second number01000110
Result00001110

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.

Questions people ask

What are the rules for adding binary digits?

0 + 0 = 0, 0 + 1 = 1, and 1 + 1 = 10, which means write 0 and carry 1. With a carry coming in, 1 + 1 + 1 = 11, which means write 1 and carry 1. Work from the right, one column at a time.

What is overflow?

Overflow happens when the result of an addition is too big for the number of bits available. In 8 bits the largest value is 255, so a result of 256 or more needs a ninth bit that does not exist. The stored answer is then wrong.

How do I know an 8-bit addition has overflowed?

Look at the left-most column. If adding it produces a carry out, there is a ninth bit and the result has overflowed. You can also check by converting both numbers to denary: if the sum is greater than 255, it overflows.

What does a computer do when overflow happens?

The processor keeps only the 8 bits that fit, so the stored value is wrong, and it can flag the overflow so that a program can respond. The exam question usually asks you to state that the result is too large for the available bits.

Sources

  1. Cambridge IGCSE Computer Science 0478 syllabus page

Updated:

Your next step

If your binary additions are right most of the time but one carry keeps disappearing, a one-to-one teacher can watch the exact column where it happens and fix the habit behind it.

Paid one-hour trial at your assigned teacher’s confirmed rate, starting from RM80. Other fees, schedules and ongoing arrangements are confirmed directly with your teacher after the trial class.

Tuition is arranged with a parent or guardian. Send them this page on WhatsApp and they can enquire for you.

Parent or guardian? Enquire here

9,000+ students helped through our service