The Gateway to Computer Science Excellence

First time here? Checkout the FAQ!

x

+7 votes

The condition for overflow in the addition of two 2's complement numbers in terms of the carry generated by the two most significant bits is ___________.

+7 votes

Best answer

The condition for overflow in the addition of two 2's complement numbers in terms of the carry generated by the two most significant bits is when carry on MSB but not From MSB, or Carry from MSB but not on MSB. i.e.,

$$C_{out} \oplus C_{n-1} = 1.$$

**i.e. For overflow to happen during addition of two numbers in 2's complement form**

They must have same sign and result is of opposite signOverflow occurs if

1. (+A) + (+B) = −C

2.(−A) + (−B) = +C

PS: Overflow is useful for signed numbers and useless for unsigned numbers

Vishal, Overflow is the condition when result produced by addition cannot be stored in space allocated. Say You Want to add $2$, 4-bit numbers, then if result produced after addition is 5-bit, then we cannot fit the result in 4-bit, And we say Overflow has happened.

In 2's complement representation $0111 = (7)_{10}$ And performing addition : $0111 + 0111$. Result obtained is $1110 = (-2)_10$, in 2's complement representation not $14$ which should be answer. But there is not way we could represent $14$ in 2's complement representation in 4-bits. So Overflow.

- All categories
- General Aptitude 1.2k
- Engineering Mathematics 4.7k
- Digital Logic 1.9k
- Programming & DS 3.5k
- Algorithms 3k
- Theory of Computation 3.7k
- Compiler Design 1.5k
- Databases 2.8k
- CO & Architecture 2.5k
- Computer Networks 2.9k
- Non GATE 837
- Others 1.2k
- Admissions 284
- Exam Queries 398
- Tier 1 Placement Questions 17
- Job Queries 51
- Projects 7

33,712 questions

40,255 answers

114,367 comments

38,882 users