7,409 views

3 Answers

Best answer
18 votes
18 votes

Overflow detection circuit for 2's complement addition

One way to detect it is to XOR the carry in and the carry out.

  1. If the sum of two positive numbers yields a negative result, the sum has overflowed.
  2. If the sum of two negative numbers yields a positive result, the sum has overflowed.
  3. Otherwise, the sum has not overflowed.

 

It is important to note the overflow and carry out can each occur without the other. In unsigned numbers, carry out is equivalent to overflow. In two's complement, carry out tells you nothing about overflow.

The reason for the rules is that overflow in two's complement occurs, not when a bit is carried out out of the left column, but when one is carried into it. That is, when there is a carry into the sign. The rules detect this error by examining the sign of the result. A negative and positive added together cannot overflow, because the sum is between the addends. Since both of the addends fit within the allowable range of numbers, and their sum is between them, it must fit as well.

selected by
0 votes
0 votes

Condition for the overflow to occur-

-Is we add 2N bit 2’s complement and the answer is too large to fit into the N bit range then overflow occur.

-When we add the 2 positive no and the result is negative,

-When we add the 2 negative no and the result is positive.

-It can also be checked by the C-in and the C-out of the MSB bit.

If the  C-in \neqC-out hence overflow.

in put to the XOR gate : C -in and C-out

Output to XOR gate is : Overflow

So when the input to XOR gate is different then the Output(Overflow ) will be 1.

So XOR gate can be used to detect the overflow.

https://stackoverflow.com/questions/32805087/how-is-overflow-detected-in-twos-complement

 

Answer:

Related questions

5 votes
5 votes
2 answers
1
makhdoom ghaya asked May 13, 2016
2,906 views
The binary equivalent of the decimal number $42.75$ is$101010 . 110$$100110 . 101$$101010 . 101$$100110 . 110$
7 votes
7 votes
6 answers
2
makhdoom ghaya asked Apr 26, 2016
6,974 views
Two eight bit bytes $1100 0011$ and $0100 1100$ are added. What are the values of the overflow, carry and zero flags respectively, if the arithmetic unit of the CPU use...
5 votes
5 votes
1 answer
3
makhdoom ghaya asked Apr 26, 2016
5,314 views
The number $1102$ in base $3$ is equivalent to $123$ in which base system?$4$$5$$6$$8$
10 votes
10 votes
4 answers
4
makhdoom ghaya asked Apr 26, 2016
6,996 views
When two $\text{BCD}$ numbers $0\times14$ and $0\times08$ are added what is the binary representation of the resultant number ?$0\times22$$0\times1c$$0\times16$results in...