Signed addition overflow rule: In two's-complement arithmetic, overflow can occur when adding two signed numbers under which condition?

Difficulty: Easy

Correct Answer: they have the same sign

Explanation:


Introduction / Context:
Detecting overflow in signed two's-complement addition is essential for reliable arithmetic units and software that checks bounds. Overflow indicates the true mathematical result is out of range for the chosen word width and cannot be represented exactly.


Given Data / Assumptions:

  • Two's-complement representation is used.
  • Word width is fixed (for example, 8, 16, 32 bits).
  • We are adding two signed integers.


Concept / Approach:
In two's-complement, overflow occurs if and only if adding two positives yields a negative, or adding two negatives yields a positive. This requires that the addends have the same sign, and the sign of the result differs from that sign. If the addends have opposite signs, the result moves toward zero and cannot overflow the representable range.


Step-by-Step Solution:

Case 1: positive + positive → overflow if result sign bit is 1.Case 2: negative + negative → overflow if result sign bit is 0.Case 3: opposite signs → result in range; no overflow.Therefore, same-sign addition is the necessary condition for overflow.


Verification / Alternative check:
Hardware rule: overflow flag V = Cout(msb) XOR CarryInto(msb). This condition triggers only when same-sign addition produces a sign flip in the result, confirming the conceptual rule.


Why Other Options Are Wrong:
Opposite signs cannot overflow in two's-complement; “both” and “none” contradict the established overflow criterion.


Common Pitfalls:
Confusing carry out of the MSB with signed overflow; relying solely on the carry flag instead of the dedicated signed overflow indicator.


Final Answer:
they have the same sign

More Questions from Number Systems and Codes

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion