GATE CS 2024 Set 1 | Question 13

MCQ · 1 mark · −0.33

Consider a system that uses 5 bits for representing signed integers in 2’s complement format. In this system, two integers \(A\) and \(B\) are represented as \(A\)=01010 and \(B\)=11010. Which one of the following operations will result in either an arithmetic overflow or an arithmetic underflow?

  1. Option A: \(A + B\)
  2. Option B: \(A - B\) (correct)
  3. Option C: \(B - A\)
  4. Option D: \(2 * B\)

Answer

(B)

Explanation

With 5 bits, 2’s complement covers \(-16\) to \(+15\). Decode the operands: \(A = 01010 = +10\), and \(B = 11010 = -6\) (invert and add 1 to get \(00110 = 6\)).

  • \(A + B = 4\): in range.
  • \(A - B = 10 + 6 = 16\): above \(+15\), so it overflows; the 5-bit result 10000 would read as \(-16\).
  • \(B - A = -16\): exactly the most negative value, so it fits.
  • \(2 * B = -12\): in range.

Only \(A - B\) leaves the representable range.

Answer: B