Study Guide
Binary Addition and Overflow
How to add two 8-bit binary numbers column by column with carries, and why an 8-bit register gives a wrong answer when the true result is greater than 255.
Lesson 1.3 Data Representation
For: Cambridge IGCSE Computer Science learners, or anyone who can already convert between binary and denary
Stage: Think
Adding on paper
A school tuckshop till adds up two lots of takings in pence: 58 and 67. (The school and its till are fictional.) You are going to add them in columns, the way you were taught at primary school.
Think it through
Add 58 and 67 in columns, starting from the right. What do you do when the ones column adds up to more than 9, and what do you do in the tens column afterwards?
- Hint 1: 8 + 7 is 15, but a column can hold only one digit.
- Hint 2: After dealing with the ones, what is added in the tens column?
Show what happens
In the ones column 8 + 7 = 15: write the 5 and carry the 1 into the tens column. In the tens column 5 + 6 + the carried 1 = 12: write the 2 and carry the 1 into the hundreds column. The answer is 125. A column that adds up to more than one digit can hold writes the last digit and carries the rest to the next column on its left.
Stage: Discover
One column in binary
Binary addition follows exactly the same plan, with a smaller set of digits: a column can only write 0 or 1.
Think it through
In one binary column, what would you write for 1 + 1, given that the digit 2 does not exist? What would you do with the rest?
- Hint 1: What does 1 + 1 equal in denary? How is that number written in binary, using the columns 2 and 1?
Show what happens
1 + 1 = 2, and two in binary is 10: a 1 in the twos column and a 0 in the ones column. So the column writes 0 and carries 1 into the next column on the left, where each unit is worth two.
A column in the middle of a sum adds up to three things: the bit from the first number, the bit from the second number and any carry in from the column to its right. Each is 0 or 1, so the column total is 0, 1, 2 or 3. In each case, write the part that fits in one binary digit and carry the rest:
| Column total | In binary | Write | Carry to the next column |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 1 | 1 | 1 | 0 |
| 2 | 10 | 0 | 1 |
| 3 | 11 | 1 | 1 |
Do not memorise this table: for any total, the digit written is the right-hand digit of its binary form, and the carry is the left-hand digit.
Check your understanding
Show the answer
Answer: B. Write 1 and carry 1, because the total is 3, which is 11 in binary.
The total is 1 + 1 + 1 = 3, which is 11 in binary. A column holds one digit, so it writes 1 and carries 1.
Stage: Explain
Adding two 8-bit numbers
Think it through
Add 00000101 and 00000011 column by column, starting from the right. Then check your answer by converting all three numbers to denary.
- Hint 1: The right-hand column is 1 + 1. What do you write, and what do you carry?
- Hint 2: Remember to add the carry in the next column as well.
Show a model answer
Column by column from the right: 1 + 1 = 2, write 0 and carry 1. Next 0 + 1 + 1 = 2, write 0 and carry 1. Next 1 + 0 + 1 = 2, write 0 and carry 1. Next 0 + 0 + 1 = 1, write 1 and carry nothing. The rest are 0. The answer is 00001000. Check: 5 + 3 = 8, and 00001000 is 8.
First the two numbers in denary, so that the answer can be checked: 00101101 is 32 + 8 + 4 + 1 = 45, and 00011011 is 16 + 8 + 2 + 1 = 27. The answer should be 72.
Call the first number A and the second number B. The table works from the right-hand column (the 1s) to the left, which is the order of the working. The Answer column, read from the bottom to the top, is the answer.
| Column | A | B | Carry in | Answer |
|---|---|---|---|---|
| 1s | 1 | 1 | 0 | 0 |
| 2s | 0 | 1 | 1 | 0 |
| 4s | 1 | 0 | 1 | 0 |
| 8s | 1 | 1 | 1 | 1 |
| 16s | 0 | 1 | 1 | 0 |
| 32s | 1 | 0 | 1 | 0 |
| 64s | 0 | 0 | 1 | 1 |
| 128s | 0 | 0 | 0 | 0 |
- Start at the right, because carries move left. In the ones column, 1 + 1 = 2: write 0, carry 1.
- Add the carry into the next column. In the twos column, 0 + 1 + 1 (carry) = 2: write 0, carry 1.
- Keep going. The fours column is 1 + 0 + 1 = 2: write 0, carry 1. The eights column is 1 + 1 + 1 = 3: write 1, carry 1. The sixteens column is 0 + 1 + 1 = 2: write 0, carry 1. The thirty-twos column is 1 + 0 + 1 = 2: write 0, carry 1.
- Finish at the left. The sixty-fours column is 0 + 0 + 1 = 1: write 1, carry nothing. The 128s column is 0 + 0 + 0 = 0.
- Read the answer and check it. The answer is 01001000, which is 64 + 8 = 72. That matches 45 + 27.
Now try one with the first rows done for you. Add A = 0110 1011 (107 in denary) and B = 0011 0110 (54 in denary), one column at a time, from the right. The answer should be 161.
| Column | Bit of A | Bit of B | Carry in | Total | Write | Carry out |
|---|---|---|---|---|---|---|
| 1s | 1 | 0 | 0 | 1 | 1 | 0 |
| 2s | 1 | 1 | 0 | 2 | 0 | 1 |
| 4s | 0 | 1 | 1 | 2 | 0 | 1 |
| 8s | 1 | 0 | 1 | |||
| 16s | 0 | 1 | 1 | |||
| 32s | 1 | 1 | 1 | |||
| 64s | 1 | 0 | 1 | |||
| 128s | 0 | 0 | 1 |
- Total is the bit of A plus the bit of B plus the carry in.
- Write the right-hand digit of the total’s binary form. Carry the left-hand digit.
- A column total of 2 is 10 in binary: write 0, carry 1. A total of 3 is 11: write 1, carry 1.
Show the completed table
| Column | Bit of A | Bit of B | Carry in | Total | Write | Carry out |
|---|---|---|---|---|---|---|
| 1s | 1 | 0 | 0 | 1 | 1 | 0 |
| 2s | 1 | 1 | 0 | 2 | 0 | 1 |
| 4s | 0 | 1 | 1 | 2 | 0 | 1 |
| 8s | 1 | 0 | 1 | 2 | 0 | 1 |
| 16s | 0 | 1 | 1 | 2 | 0 | 1 |
| 32s | 1 | 1 | 1 | 3 | 1 | 1 |
| 64s | 1 | 0 | 1 | 2 | 0 | 1 |
| 128s | 0 | 0 | 1 | 1 | 1 | 0 |
Check your understanding
Show the answer
Answer: A. Read from the bottom (128s) to the top, the Write column gives 10100001, which is 161 and matches 107 + 54.
The bits are written 1, 0, 1, 0, 0, 0, 0, 1 from the 128s column to the 1s column: 10100001 = 128 + 32 + 1 = 161. And 107 + 54 = 161. The last column totalled only 1, so nothing was carried past it.
Stage: Experiment
Adding on your own
Now add without the column table. Work from the right, write each carry above the next column, and check each answer in denary.
| First number | Second number | Answer |
|---|---|---|
| 0000 1101 | 0000 0111 | |
| 0101 0101 | 0010 1010 | |
| 1001 0110 | 0100 0011 | |
| 0011 1111 | 0000 0001 |
- Write the carries above the columns as you go.
- Check by converting both numbers and your answer to denary.
Show the completed table
| First number | Second number | Answer |
|---|---|---|
| 0000 1101 | 0000 0111 | 0001 0100 |
| 0101 0101 | 0010 1010 | 0111 1111 |
| 1001 0110 | 0100 0011 | 1101 1001 |
| 0011 1111 | 0000 0001 | 0100 0000 |
Check your understanding
Show the answer
Answer: C. 1000 1000, which is 136, matching 99 + 37.
0110 0011 is 99 and 0010 0101 is 37. Column by column the sum is 1000 1000, which is 128 + 8 = 136 = 99 + 37.
Stage: Think
A counter that runs out
A fictional toy car has a mileage counter made of three wheels, so it can show 000 to 999. The counter shows 998 and the car drives 5 more miles.
Think it through
What does the counter show after the 5 miles? Is it showing the right distance, and what has gone wrong?
- Hint 1: 998 + 5 is 1003. How many digits is that?
- Hint 2: How many digits does the counter have room for?
Show what happens
It shows 003. The true answer, 1003, has four digits, but the counter has only three wheels, so the leading 1 has nowhere to go and is lost. The counter shows a wrong answer without any warning.
Stage: Explain
Overflow in an 8-bit register
Inside a processor, numbers are held in a register: a small store with a fixed number of bits. An 8-bit register has exactly eight columns, worth 128, 64, 32, 16, 8, 4, 2 and 1. With every bit on it holds 255, and it has no column for 256.
If an addition makes a result greater than 255, the carry out of the leftmost column has nowhere to go. This is overflow: the register size limits the value that can be stored, so the answer held is wrong.
200 is 1100 1000 (128 + 64 + 8) and 100 is 0110 0100 (64 + 32 + 4). The true answer is 300, which is more than 255.
Calling the numbers A and B again, the table works from the 1s column to the left. The register has no 256s column: the last row is shown only to see where the carry goes.
| Column | A | B | Carry in | Answer |
|---|---|---|---|---|
| 1s | 0 | 0 | 0 | 0 |
| 2s | 0 | 0 | 0 | 0 |
| 4s | 0 | 1 | 0 | 1 |
| 8s | 1 | 0 | 0 | 1 |
| 16s | 0 | 0 | 0 | 0 |
| 32s | 0 | 1 | 0 | 1 |
| 64s | 1 | 1 | 0 | 0 |
| 128s | 1 | 0 | 1 | 0 |
| 256s | – | – | 1 | 1, lost |
- Add as before, from the right. The 1s column is 0 + 0 = 0 and the 2s column is 0 + 0 = 0. The 4s column is 0 + 1 = 1, the 8s column is 1 + 0 = 1, the 16s column is 0 + 0 = 0 and the 32s column is 0 + 1 = 1. None of these carries anything.
- Reach the 64s column. 1 + 1 = 2: write 0, carry 1.
- Reach the 128s column. 1 + 0 + 1 (carry) = 2: write 0, carry 1. This carry belongs in a 256s column, but the register has no ninth bit, so it is lost.
- Read what the register keeps. The register holds 0010 1100, which is 32 + 8 + 4 = 44, not 300. The lost carry was worth 256, and 300 − 256 = 44.
A 1 in the leftmost bit is not overflow. 1100 1000 starts with a 1, and it is a perfectly good 200. Overflow means the true result is greater than 255, so that it needs a ninth bit.
Check your understanding
Show the answer
Answer: A. 128 + 129, because the answer is 257.
200 + 55 = 255 and 100 + 100 = 200 both fit in eight bits. 128 + 129 = 257 does not, so it overflows, and the register would hold 257 − 256 = 1.
Stage: Apply
Use it somewhere new
Apply it
A fictional game keeps a player’s coins in an 8-bit register. The player has 250 coins and collects 10 more.
Apply it
Show the answer
Answer: D. 4, because 260 is 256 more than 4 and the extra 256 is lost.
250 is 1111 1010 and 10 is 0000 1010. Their sum is 1 0000 0100: the leading 1 is the lost 256, and the register holds 0000 0100, which is 4. The coins have wrapped round, so the player appears to have 4.
Complete the table: add each pair in an 8-bit register, write what the register holds, and say whether the addition overflows.
| First number | Second number | Register holds | Overflow? (Yes or No) |
|---|---|---|---|
| 0100 1100 | 0010 0110 | ||
| 1011 0110 | 0100 1010 | ||
| 1111 0000 | 0001 0001 | ||
| 1001 0001 | 0110 1110 |
- Add the numbers, and write any ninth bit separately.
- Convert to denary to check: is the total greater than 255?
Show the completed table
| First number | Second number | Register holds | Overflow? (Yes or No) |
|---|---|---|---|
| 0100 1100 | 0010 0110 | 0111 0010 | No |
| 1011 0110 | 0100 1010 | 0000 0000 | Yes |
| 1111 0000 | 0001 0001 | 0000 0001 | Yes |
| 1001 0001 | 0110 1110 | 1111 1111 | No |
Stage: Consolidate
Bring it together
Think it through
Without looking back, explain to a friend what overflow is and why it happens in an 8-bit register, using an example of your own.
Show a model answer
A good answer says that a register has a fixed number of bits, so an 8-bit register can hold only 0 to 255. If an addition produces a result greater than 255, it needs a ninth bit that the register does not have, so the carry is lost and the value stored is wrong. For example, 255 + 1 = 256 would need nine bits, and the register would hold 0000 0000.
Check your understanding
Show the answer
Answer: B. The register holds 0000 0000, and overflow has happened.
1111 1111 + 0000 0001 gives a carry that runs through every column and leaves a 1 beyond the leftmost one. That 1 is lost, so the register holds 0000 0000 even though 256 visitors have entered.
- To add binary numbers, work from the right, one column at a time. Each column totals the two bits and any carry in: a total of 0 or 1 is written as it is, 2 writes 0 and carries 1, and 3 writes 1 and carries 1.
- Check an addition by converting both numbers and the answer to denary.
- A register holds a fixed number of bits. An 8-bit register holds 0 to 255.
- Overflow happens when an addition produces a value greater than 255 in an 8-bit register: the carry out of the leftmost column has nowhere to go and is lost, so the stored result is wrong (the true answer less 256).
- A leading 1 does not mean overflow. Compare the true result with 255.
Sources and scope
- What this lesson is. The third lesson of the Data Representation module, written for this site. It teaches point 4 of Cambridge IGCSE Computer Science 1.1 (adding two positive 8-bit integers, and overflow) against the 2026 to 2028 syllabus (version 6). Its curriculum links are provisional: no link has been verified by the site owner. They show where the lesson may help with a course and imply no review or endorsement by any examination board.
- Original material. The school tuckshop, the three-wheel toy car, Priya, the coin game and the museum turnstile are fictional examples written for this lesson.
- Simplified on purpose. Only positive integers are added, and an overflowed result is shown as the register would hold it, with the lost carry discarded. Real programs and processors may detect an overflow and report an error, use a larger register (16, 32 or 64 bits), or limit a value at its maximum instead. Negative numbers and subtraction are not taught here.
The number system with only two digits, 0 and 1, in which each column is worth twice the column to its right.
A single binary digit: 0 or 1. The smallest unit of data a computer stores.
The digit passed to the next column on the left when a column adds up to more than one digit can hold.
The everyday number system with ten digits, 0 to 9, in which each column is worth ten times the column to its right.
What happens when a calculation produces a value too big for the register that has to store it, so the result stored is wrong.
A very small, very fast storage location inside the CPU that holds a fixed number of bits: the address, data or instruction the CPU is working on at that moment.
Your progress on this lesson
Saved in this browser only. It is not sent anywhere, does not follow you to another device, and is lost if you clear this site’s data.
This browser is not allowing the site to save progress, so it will be forgotten when you leave the page.