[Math] Binary arithmetic – overflow and carryout at same time

arithmeticbinary

In binary arithmetic, When you subtract 2 signed numbers you must discard the carry out. My question is, is it possible for overflow to occur and a carry out? So, on paper there would be two extra bits and you would have to discard one?

Also, if your subtracting 2 signed numbers, how do you differentiate between overflow and a carry out?

Best Answer

Overflow and carry out are philosophically the same thing. Both indicate that the answer does not fit in the space available. The difference is that carry out applies when you have somewhere else to put it, while overflow is when you do not. As an example, imagine a four bit computer using unsigned binary for addition. If you try to add $1010_2+111_2$ without the word length restriction, you get $10001_2$ The high bit does not fit in our word. If this word is all the space allocated to this variable, it represents overflow as the result is too large to represent. If we have a two word space allocated to this variable, it becomes a carry out and is stored in the higher word. We would then represent the addition as $0000\ 1010_2+0000\ 0111_2=0001\ 0001_2$ and the carry is explicit.