Using a 4-bit 2’s complement arithmetic, which of the following additions will result in an overflow?
- 1100 + 1100
- 0011 + 0111
- 1111 + 0111
(A) (i) only
(B) (ii) only
(C) (iii) only
(D) (i) and (iii) only
Explanation: The rules for detecting overflow in a two’s complement sum are :
- If the sum of two positive numbers yields a negative result;(+A) + (+B) = −C
- If the sum of two negative numbers yields a positive result;(−A) + (−B) = +C
- Otherwise, the sum has not overflowed.
4-bit Two’s Complement numbers range from (−8 ≤ x ≤ +7); Only ii will cause overflow after solving
- Another way to detect: The OVERFLOW flag is the XOR of the carry coming into the sign bit (if any) with the carry going out of the sign bit (if any). Overflow happens if the carry in does not equal the carry out