Hardware works with a fixed number of bits. Overflow happens when the correct answer is outside the range those bits can show, so the result you get is the wrong number.
The same addition can overflow under one reading and not the other, so there are two tests:
- Unsigned overflow: the addition produced a carry out of the MSB. The true sum needed one more bit.
- Signed overflow (twos complement): two operands with the same sign gave a result with the opposite sign. Adding numbers of different signs never overflows. In hardware: the carry into the MSB differs from the carry out of it.
The two tests are independent. All four combinations happen (see the example), so never judge one from the other.
Why it happens: fixed-width arithmetic wraps around. In 4 bits, 15 + 1 rolls over to 0 (unsigned), and +7 + 1 rolls over to −8 (signed).
An ALU records both verdicts as status flags: C for the carry-out and V for signed overflow. The program checks whichever matches its data type.