GATE / CS ARCHIVE

GATE CSE 2019 / QUESTION 8

Width required for sign-magnitude subtraction

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

GATE 2019, Q8 1 mark · MCQ
Report issue

Number Systems & Computer Arithmetic

Question 8, GATE 2019: X and Y use n-bit sign-magnitude representations, and Z = X − Y must also use sign magnitude. Find the minimum width that avoids overflow for all operands. Choices: A n; B n−1; C n+1; D n+2 bits.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Method: find the largest possible magnitude of a difference, then reserve a separate sign bit.

1. In an n-bit sign-magnitude number, one bit is the sign and n − 1 bits encode the magnitude. Thus each operand has absolute value at most M = 2n−1 − 1.
2. The largest positive difference occurs at X = M and Y = −M, giving Z = 2M = 2n − 2. Reversing these operands produces the negative extreme of the same magnitude.
3. For n ≥ 2, n − 1 magnitude bits cannot hold 2n − 2, but n magnitude bits can, since their maximum is 2n − 1. Therefore n magnitude bits are necessary and sufficient.
4. Add the sign bit: the result needs n + 1 total bits. For example, with n = 4, inputs range from −7 to +7; their difference can be +14, requiring four magnitude bits plus a sign.

Result: C, n+1 bits. The degenerate n=1 format represents only signed zero and is outside the usual nontrivial-width interpretation.

Original paper, page 5 · Answer key