• For integer values and in the range

Visual demonstration

Case 1 and Case 4 demonstrate overflow situations

Examples

Case
-8 [1000]-5 [1011]-13 [10011]3 [0011]1
-8 [1000]-8 [1000]-16 [10000]0 [0000]1
-8 [1000]5 [0101]-3 [11101]-3 [1101]2
2 [0010]5 [0101]7 [00111]7 [0111]3
5 [0101]5 [0101]10 [01010]-6 [1010]4

The column “Case” corresponds to the “Case” shown in the figure above

Detecting overflow in two’s complement addition

  • Assume
  • Then is a positive overflow if and only if and but .
  • The computation is a negative overflow if and only if and but

Sources