The Gateway to Computer Science Excellence
+5 votes
4.8k views

Which logic gate is used to detect overflow in 2's compliment arithmetic?

  1. OR gate
  2. AND gate
  3. NAND gate
  4. XOR gate
in Digital Logic by Boss (30.8k points) | 4.8k views

2 Answers

+17 votes
Best answer

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.

by Boss (45.4k points)
selected by
+4 votes
Xor gate is used .
by Loyal (9.9k points)
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,737 questions
57,297 answers
198,265 comments
104,977 users