IAE Academy

GATE 2024 CS1 Q.13: solution and answer

GATE 2024 · CS1Q.13 · 1 mark · MCQ

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. (A)

    A + B

  2. (B)

    A − B

  3. (C)

    B − A

  4. (D)

    2 * B

See the question in the paper

Answer and solution

ANSWER

Option (B): exceeds the largest 5-bit 2's complement value, 15, so it overflows.

Official answer: BSource: Official answer key, GATE 2024 CS1 (IISc Bengaluru)

  1. A 5-bit 2's complement number lies in . A result outside this range is an overflow (above 15) or an underflow (below ).

  2. Decode : the sign bit is 0, so .

  3. Decode : the sign bit has weight , so .

  4. (A) , which is inside . No overflow.

  5. (B) , which is greater than 15 and cannot be held in 5 bits (it would wrap to ). This is an arithmetic overflow.

  6. (C) , which is exactly the minimum, . It is representable, so there is no underflow.

  7. (D) , which is inside the range. It is also representable, as .

  8. Only leaves the representable range, so the answer is (B).

KEY IDEA

Decode both operands to decimal, compute the exact result, and compare it with the range . For that range is .

WATCH OUT FOR

Reading as by flipping the bits without adding 1, or as . Another slip is calling an underflow, when is the minimum value and is representable.

From the GATE 2024 CS1 paper. Every question of this paper · Download the full paper · All 18 Number systems questions, with notes

More Number systems questions