GATE / CS ARCHIVE

GATE CSE 1992 / QUESTION 4(a)

Signed addition overflow

Digital Logic · Number Systems & Computer Arithmetic · Full GATE CSE 1992 paper

GATE 1992, Q4(a) Descriptive
Report issue

Number Systems & Computer Arithmetic

Question 4(a), GATE 1992: Explain when addition in fixed-width two’s-complement arithmetic overflows, and why carry out of the most significant bit is not sufficient.
Tap to enlarge
Answer & solution

Answer: Overflow iff equal-sign operands produce the opposite-sign result; V = carry into sign bit XOR carry out. (no official key was published)

For a w-bit two’s-complement word the representable interval is −2w−1 through 2w−1−1. Hardware retains the low w bits of the mathematical sum. Overflow means the mathematical signed sum lies outside this interval, not merely that an unsigned carry was discarded.

Let a,b be the operand sign bits and s the retained result sign bit. The overflow flag is V=(¬a∧¬b∧s)∨(a∧b∧¬s). Two nonnegative numbers overflow only by producing a sign bit of 1; two negative numbers overflow only by producing a sign bit of 0. Opposite-sign operands cannot overflow: their sum lies between the operands and hence within the representable interval.

Equivalently, if c_in is the carry into the sign-bit adder and c_out its outgoing carry, V=c_in XOR c_out. This follows by considering the sign-bit full-adder cases: for equal operand signs an incorrect result sign occurs precisely when these carries differ; for unequal signs they agree.

For four bits, 0111+0001=1000 represents 7+1 as −8: overflow occurs despite no outgoing carry. Conversely 1111+0001=0000 with carry 1 represents −1+1=0 correctly: carry occurs without overflow. Finally 1000+1111=0111 with carry 1 is −8+(−1), which really does overflow. These examples separate the unsigned carry flag from the signed overflow flag.

Original paper, page 5