Let R1 and R2 be two 4-bit registers that store numbers in 2’s complement form. For the operation R1+R2, which one of the following values of R1 and R2 gives an arithmetic overflow?
(A)
R1 = 1011 and R2 = 1110
(B)
R1 = 1100 and R2 = 1010
(C)
R1 = 0011 and R2 = 0100
(D)
R1 = 1001 and R2 = 1111
Answer: (B)
Explanation:
The range of 2’s complement represented with 4 bits are -8 to +7
A. R1= -1* 23 + 0* 22 + 1* 21+ 1* 20 = -5
R2 = -1* 23 + 1* 22 + 1* 21+ 0* 20 = -2
R1 + R2 = -7 (no overflow)
B. R1= -1* 23 + 1* 22 + 0* 21+ 0* 20 = -4
R2 = -1* 23 + 0* 22 + 1* 21+ 0* 20 = -6
R1 + R2 = -10 (overflow)
C. R1= 0* 23 + 0* 22 + 1* 21+ 1* 20 = 3
R2 = 0* 23 + 1* 22 + 1* 21+ 0* 20 = 4
R1 + R2 = 7 (no overflow)
D. R1= -1* 23 + 0* 22 + 0* 21+ 1* 20 = -7
R2 = -1* 23 + 1* 22 + 1* 21+ 1* 20 = -1
R1 + R2 = -8 (no overflow)
Quiz of this Question
Please comment below if you find anything wrong in the above post