Question:hard

Consider the 8-bit signed integers \( X, Y \) and \( Z \) represented using the sign-magnitude form. The binary representations of \( X \) and \( Y \) are as follows:
\[ X: 10110100 \qquad Y: 01001100 \]
Which of the following operations to compute \( Z \) result(s) in an arithmetic overflow?

Show Hint

Overflow in sign-magnitude addition happens only when two same-signed operands' magnitudes add up to more than 127 (7-bit limit); opposite-signed operands only ever subtract magnitudes and can never overflow.
Updated On: Jul 22, 2026
  • \( Z = X + Y \)
  • \( Z = X - Y \)
  • \( Z = -X + Y \)
  • \( Z = -X - Y \)
Show Solution

The Correct Option is B, C

Solution and Explanation

Method: Perform each operation by literally adding or subtracting the 7-bit magnitudes according to the signs, the way a sign-magnitude ALU would, and check whether the resulting magnitude fits in 7 bits (max 127).
Decoded values: X = -52 (magnitude 0110100), Y = +76 (magnitude 1001100).
(A) X+Y: opposite signs, subtract smaller magnitude from larger: 76-52=24, sign follows the larger-magnitude operand (positive). Result +24, fits in 7 bits. No overflow.
(B) X-Y = X+(-Y): both operands negative (X=-52, -Y=-76), same-sign addition: 52+76=128, sign negative. Result -128; magnitude 128 needs 8 bits, cannot be stored in 7 bits: overflow.
(C) -X+Y: -X=+52 and Y=+76, both positive, same-sign addition: 52+76=128, sign positive. Result +128, again needs 8 magnitude bits: overflow.
(D) -X-Y = (-X)+(-Y): -X=+52 and -Y=-76, opposite signs, subtract magnitudes: 76-52=24, sign follows the larger magnitude operand -Y (negative). Result -24, fits comfortably in 7 bits. No overflow.
So overflow happens exactly for (B) and (C), where two same-signed operands' magnitudes sum past 127.
\[ \boxed{\text{Options (B) and (C)}} \]
Was this answer helpful?
0

Top Questions on Number Representation - Sign-Magnitude Arithmetic and Overflow


Questions Asked in GATE CS exam