SLIDE 1
CSZone.co.uk
Click to reveal · Arrow keys also work
OCR J277 · Component 1 · Topic 1.2.4c

Binary Arithmetic
and Overflow

Adding 8-Bit Binary Numbers · Carrying · Overflow Errors · Exam Practice

CSZone OCR GCSE Computer Science J277
Learning Objectives

By the end of this video you will be able to...

Add together two 8-bit binary integers using column addition
Apply the binary addition rules, including carrying a 1 into the next column
Explain what an overflow error is and when one occurs
Work out the stored 8-bit result when an addition causes overflow, and identify it as incorrect
Apply all of this to exam-style questions
⚡ Builds directly on the place value method from 1.2.4a — the same 8-bit columns: 128, 64, 32, 16, 8, 4, 2, 1
Binary Addition

Four rules for adding binary digits

Binary addition works just like denary column addition — but there are only four possible cases for each column.
0 + 0 = 0
Two zeros add to zero. Nothing to carry.
0 + 1 = 1
1 + 0 = 1
Either order, a 0 and a 1 add to 1. Still nothing to carry.
1 + 1 = 10
Two 1s add to denary 2, which is "10" in binary. Write 0 in this column and carry 1 into the next column to the left.
1 + 1 + 1 = 11
If there's already a carry-in of 1, then 1 + 1 + 1 = denary 3, which is "11" in binary. Write 1 in this column and carry 1 into the next column.
Binary Addition

Method: column addition with carrying

STEP-BY-STEP METHOD
Step 1: Write the two 8-bit numbers one under the other, aligned by place value — 128, 64, 32, 16, 8, 4, 2, 1
Step 2: Starting at the rightmost column (the 1s), add the two bits in that column plus any carry from the column to its right
Step 3: Write the result digit below the line. If the total is 2 or 3, carry a 1 into the next column to the left
Step 4: Repeat for each column, moving left, until you reach the 128s column
Example: Add 01001011 (75) and 00100001 (33)
Worked Example — No Overflow

75 + 33 = ?

1286432168421
75 =01001011
+ 33 =00100001
carry000011
Carries are generated in the 2s and 4s columns: 1+1=10 (write 0, carry 1)
= 10801101100
Answer: 01101100
Check: 01101100 = 64+32+8+4 = 108. And 75 + 33 = 108 ✓ — no overflow, the answer fits comfortably in 8 bits (max 255).
Overflow Errors

What is an overflow error?

DEFINITION
An overflow error occurs when the result of a binary calculation is too large to be stored in the number of bits available.
An 8-bit register (one byte) can only store values from 00000000 to 11111111 — denary 0 to 255. That's the absolute maximum.
If adding two 8-bit numbers produces a sum greater than 255, the true result needs a 9th bit — but there isn't one. An overflow error occurs.
⚡ Quick check before you even add the binary: convert both numbers to denary and add them. If the total is over 255, you already know overflow will occur.
Worked Example — Overflow

167 + 220 = ?

2561286432168421
10100111
11011100
167 = 10100111  |  220 = 11011100
carry1111110
The carries cascade all the way through — including a carry out of the 128s column into a 9th column (256)
= 11000011
Full 9-bit result: 110000011 = 256+128+2+1 = 387 — the true sum of 167 + 220
BUT ONLY 8 BITS EXIST
The 9th bit (256) doesn't fit in an 8-bit register, so it's lost. The stored result is just 10000011 = 128+2+1 = 131 — not 387. Overflow has occurred, and the stored answer is wrong.
Exam Technique

Recognising and explaining overflow

Spot it fast: before doing the binary addition, convert both numbers to denary and add them. If the total exceeds 255, the addition will overflow.
Spot it in the working: if your column addition produces a carry out of the leftmost (128s) column — i.e. a 9th bit — that's overflow.
EXAM PHRASING
"An overflow error occurs because the result of the calculation requires more bits (9 bits) than are available (8 bits) / because the result is greater than 255, the maximum value that can be stored in 8 bits."
Effect on a program: if the program isn't written to expect this, the stored result will be incorrect — the program may produce the wrong output, behave unexpectedly, or crash.
Exam Practice

Exam Question 1 — Addition (No Overflow)

Question 1 · 2 marks
Add together the binary values 01010110 and 00100111. State whether an overflow error occurs.
2 marks
1286432168421
86 =01010110
+ 39 =00100111
carry000111
= 01111101
Answer: 01111101 = 125 (86 + 39)
No overflow — there's no carry out of the 128s column, and 125 is well within the 0–255 range.
Exam Practice

Exam Question 2 — Addition (Overflow)

Question 2 · 2 marks
Add together the binary values 11001000 and 01001000. If an overflow error occurs, state the value that would be stored.
2 marks
2561286432168421
11001000
01001000
200 = 11001000  |  72 = 01001000
carry1100100
= 10001000
9-bit true result: 100010000 = 256 + 16 = 272 (200 + 72)
OVERFLOW OCCURS
272 needs 9 bits, but only 8 are available. The 256 bit is lost. Stored value = 00010000 = 16.
Exam Practice

Exam Question 3 — Explain Overflow

Question 3 · 3 marks
Explain what is meant by an overflow error, and describe the effect it could have on a computer program.
3 marks
M1
An overflow error occurs when the result of a calculation is too large / requires more bits than the register or memory location has available.
M2
For an 8-bit register, the maximum storable value is 255 — if a calculation produces a result greater than 255, the extra (9th) bit cannot be stored.
M3
The effect is that the stored result will be incorrect — the program may produce the wrong output, behave unexpectedly, or crash.
⚡ Three separate marking points — cover the cause (too many bits needed), the limit (255 for 8 bits), and the effect (wrong result / unexpected behaviour).
Common Mistakes

Four mistakes that cost marks in the exam

1
Writing "10" instead of carrying. When 1 + 1 = 2, you cannot write "2" or "10" in a single binary column. Write 0 in that column and carry the 1 into the next column to the left.
2
Forgetting a carry-in. Each column can have THREE values to add if there's a carry from the column on the right: the two digits plus the carry. Forgetting the carry-in gives a completely wrong answer.
3
Not checking for overflow at all. Always check: does the carry go out of the leftmost (128s) column? Or is the denary sum over 255? If either is true, overflow has occurred.
4
Giving the 9-bit answer instead of the stored 8-bit answer. If asked what value would be stored after overflow, the 9th bit is dropped — give the remaining 8 bits (e.g. 131, not 387).
Summary

1.2.4c — Binary Arithmetic and Overflow

ADDITION RULES
0+0=0, 0+1=1, 1+1=10 (write 0, carry 1), 1+1+1=11 (write 1, carry 1)
METHOD
Add column by column from the 1s upward, carrying into the column to the left when needed
NO OVERFLOW EXAMPLE
75 + 33 = 01101100 = 108 — fits in 8 bits
OVERFLOW
Occurs when a sum needs 9+ bits / exceeds 255 — the extra bit is lost, giving an incorrect stored result
OVERFLOW EXAMPLE
167 + 220 = 387, but only 10000011 = 131 is stored
⚡ Exam phrasing: overflow occurs because the result requires more bits than are available, and causes an incorrect stored result / unexpected program behaviour.
CSZone.co.uk

That's 1.2.4c done.

Next up: 1.2.4d — Binary Shifts

Full quiz, instantly marked worksheet and slides at CSZone.co.uk