Addition and overflow in two’s complement
In two’s complement you add as usual. If the result leaves the range, an overflow occurs.
Rules
- Add bits normally; a carry past the width is dropped
- Overflow: both addends have the same sign, the result the other
- Different signs can never overflow
Your turn
Three problems on this topic. Spaces don’t matter.
- 1 · Addition & overflow
- 2
- 3
Add the two 8-bit numbers in two’s complement.
1000 1000 + 1111 1001
Result (8 bits)
Interpreted value
Overflow?
Type numbers without a prefix, spaces don’t matter. With a fixed bit width give all the bits.
Worked example
Add the two 8-bit numbers in two’s complement.
0100 0101 + 1100 0110
Worked solution
- 169 + (−58) = 11
- 2Bits, dropping any carry past bit 8: 0000 1011
- 3The result lies within −128 to 127: no overflow.
Typical mistake: Overflow only occurs when both addends have the same sign and the result has the other.
Common questions
Is a carry out of the top bit an overflow?
No, those are two different things.
