4.2Overflow
The idea
Overflow means the true result does not fit in the available bits, so the stored result is wrong.
Think of it like this: An odometer rolling over from 9999 to 0000.
Why it exists
The hardware never raises an error by itself; software or flags must catch it.
How it works
- Adding two positives that give a negative (or two negatives giving a positive) is signed overflow.
- Hardware test: V = (carry into the sign bit) XOR (carry out of the sign bit).
- Carry out of the top bit is the unsigned overflow signal.
- Adding numbers of opposite signs never overflows.
Worked example: 4-bit: 5 + 3
0101 + 0011 = 1000 which reads as −8. Carry in = 1, carry out = 0, V = 1: overflow.
Now play with it
- →Try 5 + 3, then 5 + 2, then −8 + −1 and watch V.
Try 5 + 3 (positive + positive gives negative) and -8 + -1.
Check yourself
In 2's complement, adding two positive numbers produces a negative result. This indicates:
Exam notes (the dense version)
Adding two same-sign numbers and getting opposite sign. Hardware: V = Cin ⊕ Cout of the MSB. Unsigned overflow = carry out of MSB.
Previous year questions: Number Representation & Computer Arithmetic (19)
PYQs are grouped by topic, so this is the full set for Number Representation & Computer Arithmetic; try the ones that match this subtopic. Open all 19 on the topic page.