Overflow: 100 + 100 in 8-bit signed — two's complement

corecarry out is not overflow

Answer

11001000

Why this example is worth doing

Two positive numbers whose sum exceeds +127 produce a negative result. The page states the detection rule precisely: signed overflow occurred when the carry into the sign bit differs from the carry out of it, which is not the same as the carry out being 1. Conflating carry and overflow is the classic error, and processors keep them as two separate status flags for exactly this reason.

Try your own input in the Two’s complement. Encode and decode signed binary at any width, with overflow and sign extension.

How the answer is reached

01100100 + 01100100 (8-bit, two's complement)

01100100 + 01100100 (8-bit, two's complement) — columns operand, bits, hex, unsigned, signed
operandbitshexunsignedsigned
A011001000x64100100
B011001000x64100100
The digit above column i is the carry or borrow into column i. Bit 0 is the least significant column. — 01100100 + 01100100
row76543210
carry in11001000
A01100100
+ B01100100
result11001000

C = 0 · V = 1 · N = 1 · Z = 0

unsigned100 + 100 = 200, kept as 200fits in the width

signed100 + 100 = 200, kept as -56V = 1: the signed answer is wrong

Warning:

C is carry-out (unsigned overflow); V is carry-into-MSB XOR carry-out-of-MSB (signed overflow). They are independent: either, both or neither can be set.

Compare with

Open the Two’s complement

This input is entered in the tool itself — it is too rich for a link to carry.

Note:

Notation this page assumes

  • Bit strings are written most significant bit first, and bit 0 is the least significant bit.
  • A width is stated explicitly wherever it changes the answer; nothing is silently sign-extended or truncated.
  • Negative values are two’s complement, not sign–magnitude, and the most significant bit is the sign bit.

Sources

  • Knuth, The Art of Computer Programming, Vol. 2, §4.1 “Positional Number Systems” (1997)
  • IEEE 754-2019, Standard for Floating-Point Arithmetic