Integer Overflow
A 4-bit binary number can go up to 1111. What happens if we try to add 1 to 1111? Since we can only hold 4 bits, the number wraps back to 0000.
First, refer to two's complement for signed integers.
For signed integers:
- If two numbers of opposite sign are added, overflow is impossible
- If two numbers of same sign are added and:
- the resulting sign is the same, there was no overflow
- the resulting sign is different, there was overflow, and that overflow is
The logical expression for overflow is