Consider the addition of two n-bit two’s-complement numbers bn−1bn−2…b0 and…

2017

Consider the addition of two n-bit two’s-complement numbers bn−1bn−2…b0 and an−1an−2…a0. An unsigned binary adder is used to add them. The n-bit sum is cn−1cn−2…c0, and the carry-out is cout. Which expression correctly identifies signed overflow?

GATECS2006Q39

Answer: B. an−1bn−1¬cn−1 + ¬an−1¬bn−1cn−1ConceptIn fixed-width two’s-complement addition, overflow is a signed-range error. It occurs when both operands have the same sign but the stored sum has the…

  1. A.

    cout · ¬(an−1 ⊕ bn−1)

  2. B.

    an−1bn−1¬cn−1 + ¬an−1¬bn−1cn−1

  3. C.

    cout ⊕ cn−1

  4. D.

    an−1 ⊕ bn−1 ⊕ cn−1

Attempted by 209 students.

Show answer & explanation

Correct answer: B

Concept

In fixed-width two’s-complement addition, overflow is a signed-range error.

It occurs when both operands have the same sign but the stored sum has the opposite sign. Operands of different signs cannot overflow because their exact sum lies between the two operand values.

Application

  1. Let an−1 and bn−1 be the operand sign bits, and let cn−1 be the sign bit of the stored n-bit sum.

  2. Two negative operands producing a non-negative stored sum give the sign triple (1,1,0), represented by an−1bn−1¬cn−1.

  3. Two non-negative operands producing a negative stored sum give the sign triple (0,0,1), represented by ¬an−1¬bn−1cn−1.

  4. The two cases are mutually exclusive, so OR them: V = an−1bn−1¬cn−1 + ¬an−1¬bn−1cn−1.

Cross-check

The same overflow flag equals the XOR of the carry into the sign-bit position and the final carry-out. A sign-triple truth-table check gives V = 1 only for (1,1,0) and (0,0,1), confirming the Boolean expression above.

Contrast

  • cout · ¬(an−1 ⊕ bn−1) also depends on the final carry, which is not itself a signed-overflow indicator.

  • cout ⊕ cn−1 compares the final carry with the stored sum sign bit, not the carry into and out of the sign-bit position.

  • an−1 ⊕ bn−1 ⊕ cn−1 tests odd parity of three sign-related bits rather than the two same-sign/opposite-result cases.

Therefore, the overflow condition is an−1bn−1¬cn−1 + ¬an−1¬bn−1cn−1.

Explore the full course: Iocl Engineers Officers Grade A Paper 2

Loading lesson…