← 🔢 Number Representation & Computer Arithmetic
Subtopic 2 of 9

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

  1. Adding two positives that give a negative (or two negatives giving a positive) is signed overflow.
  2. Hardware test: V = (carry into the sign bit) XOR (carry out of the sign bit).
  3. Carry out of the top bit is the unsigned overflow signal.
  4. 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.
0101 (5) + 0011 (3) = 1000 (-8) carry out = 0
Carry into MSB1
Carry out of MSB0
V = Cin ⊕ Cout1
Signed overflow?YES
Unsigned overflow (carry)?no

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:

Remember: Overflow = carry into MSB differs from carry out of MSB.
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.