The Gateway to Computer Science Excellence

First time here? Checkout the FAQ!

x

+4 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 ___________.

+5 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.1k
- Engineering Mathematics 4k
- Digital Logic 1.7k
- Programming & DS 3k
- Algorithms 2.6k
- Theory of Computation 3.2k
- Compiler Design 1.2k
- Databases 2.4k
- CO & Architecture 2.1k
- Computer Networks 2.4k
- Non GATE 819
- Others 1.1k
- Admissions 244
- Exam Queries 420
- Tier 1 Placement Questions 16
- Job Queries 39
- Projects 4

29,157 questions

36,985 answers

92,166 comments

34,824 users