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?

This question was previously asked in
GATE CS 2022 Official Paper
View all GATE CS Papers >
  1. R1 = 1011 and R2 = 1110
  2. R1 = 1100 and R2 = 1010
  3. R1 = 0011 and R2 = 0100
  4. R1 = 1001 and R2 = 1111

Answer (Detailed Solution Below)

Option 2 : R1 = 1100 and R2 = 1010
Free
GATE CS Full Mock Test
5.5 K Users
65 Questions 100 Marks 180 Mins

Detailed Solution

Download Solution PDF

The correct answer is option 2.

Concept:

Stored numbers in registers R1 and R2 are in 2's complement form. Register size is 4 bits. The range of numbers in 2's complement form is -8 to +7. If R1 + R2, the result is out of the above range, then it is overflow.

The given data,

Given two four-bit registers R1 and R2.

Option 1: R1 = 1011 and R2 = 1110

False,  

R1      =  1 0 1 1 = -(0101)= -5

+ R2   =  1 1 1 0 = -(0010)= -2

-----------------------------------------------

               1 0 0 1  =           = -7        

Here No overflow occurred, because sign bit is same for (R1 + R2 ).

Option 2: R1 = 1100 and R2 = 1010

True,

R1      =  1 1 0 0 = -(0100)= -4

+ R2   =  1 0 1 0 = -(0110)= -6

  --------------------------------------------

              0 1 1 0 =            = -10       

Here Overflow occurred because the sign bit is different for (R1 + R2 ).

Option 3: R1 = 0011 and R2 = 0100

False,

R1      =   0 0 1 1 = +(0011)= +3

+ R2   =   0 1 0 0 = +(0100)= +4

  --------------------------------------------

                0 1 1 1                 =   +7       

Here No overflow occurred, because the sign bit is the same for (R1 + R2 ).

Option 4: R1 = 1001 and R2 = 1111

False, 

R1      =   1 0 0 1 = -(0111)  = -7

+ R2   =   1 1 1 1 = -(0001) = -1

  --------------------------------------------

                1 0 0 0 =               = -8

Here No overflow occurred, because the sign bit is the same for (R1 + R2 ).

Hence the correct answer is R1 = 1100 and R2 = 1010.

Latest GATE CS Updates

Last updated on Jan 8, 2025

-> GATE CS 2025 Admit Card has been released on 7th January 2025.

-> The exam will be conducted on 1st February 2025 in 2 shifts.

-> Candidates applying for the GATE CE must satisfy the GATE Eligibility Criteria.

-> The candidates should have BTech (Computer Science). Candidates preparing for the exam can refer to the GATE CS Important Questions to improve their preparation.

-> Candidates must check their performance with the help of the GATE CS mock tests and GATE CS previous year papers for the GATE 2025 Exam.

Get Free Access Now
Hot Links: teen patti apk download online teen patti real money teen patti