Question

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

Choose one option
Official answer and solution
Official answer
B
From
Official GATE 2024 answer key

Solution

Convert the 5-bit 2's complement numbers to decimal and check which result falls outside the representable range [−16,+15][-16, +15].

In a 5-bit 2's complement system, the representable signed integer range is [−25−1,  25−1−1]=[−16,+15][-2^{5-1},\; 2^{5-1}-1] = [-16, +15].

  • A=010102=+10A = 01010_2 = +10
  • B=110102=−16+8+2=−6B = 11010_2 = -16 + 8 + 2 = -6

Evaluating each operation:

  • (A) A+B=10+(−6)=+4∈[−16,+15]A + B = 10 + (-6) = +4 \in [-16, +15] (no overflow)
  • (B) A−B=10−(−6)=+16>+15A - B = 10 - (-6) = +16 > +15, which exceeds the maximum positive value +15+15 and causes an arithmetic overflow.
  • (C) B−A=−6−10=−16∈[−16,+15]B - A = -6 - 10 = -16 \in [-16, +15] (representable as 10000210000_2, no underflow)
  • (D) 2∗B=2×(−6)=−12∈[−16,+15]2 * B = 2 \times (-6) = -12 \in [-16, +15] (no underflow)
Final answer

Option (B)

Common trap

Assuming −16-16 overflows in 5-bit 2's complement and choosing B−AB - A, forgetting that the asymmetric range [−16,+15][-16, +15] includes −16-16.

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2024 Computer Science and Information Technology - Set 1 (CS1)
Question
13 of 65
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.