GATE CS 2024 Set 1 — Question 13

MCQ+1 / -0.33MediumSigned Number RepresentationsNumber Systems & ArithmeticDigital LogicBinary Arithmetic & Overflow

Digital Logic → Number Systems & Arithmetic → Binary Arithmetic & Overflow

Last updated

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?
A.
A+BA + B
B.
ABA - B
C.
BAB - A
D.
2B2 * B

Correct answer

(B) A - B

Solution

In a 5-bit 2's complement system, the range of representable integers is from 251-2^{5-1} to 25112^{5-1}-1, i.e., from 16-16 to +15+15.
Given:
A=010102A = 01010_2. Since the MSB is 0, it is positive. Value =+10= +10.
B=110102B = 11010_2. Since the MSB is 1, it is negative. To find the magnitude, we take the 2's complement: invert bits (0010100101) and add 1 (0011000110), which is 6. So, B=6B = -6.
Let's evaluate the options:
(A) A+B=10+(6)=4A + B = 10 + (-6) = 4. This is within the range [16,15][-16, 15]. No overflow.
(B) AB=10(6)=16A - B = 10 - (-6) = 16. The maximum positive value representable is 15. Since 16>1516 > 15, an arithmetic overflow occurs.
(C) BA=610=16B - A = -6 - 10 = -16. This is within the range [16,15][-16, 15]. No overflow (16-16 is represented as 10000210000_2).
(D) 2B=2(6)=122 * B = 2 * (-6) = -12. This is within the range [16,15][-16, 15]. No overflow.
Thus, the operation ABA - B results in an overflow.

More questions on Number Systems & Arithmetic

Practice GATE CS PYQs with adaptive difficulty

Timed practice, skill tracking, and AI explanations — free to start.

Start practicing free