2’s complement (cont’d)
Just one thing: Recall the example with decimals. What happens if we add 40 and 40? We get 80, but we interpret 80 as -20…
This is called overflow. In 2’s complement addition, overflow occurs if both operands are positive but the result is negative, or if both operands are negative and the result is positive.
In 2’s complement subtraction, overflow occurs if a positive number is subtracted from a negative number and the result is positive, or if a negative number is subtracted from a positive number and the result is negative.
Don’t confuse carry and overflow...