14 / 36 · Concept
Signed values and overflow
Interpret the same bits as unsigned and two’s complement.
Lessons are free to read. Enroll to save your learning progress.
Learning goals
- Represent negative values in two’s complement.
- Distinguish carry from signed overflow.
A bit pattern needs an interpretation.
The four-bit pattern 1111 is 15 when unsigned and −1 in signed two’s complement. An N-bit signed value ranges from −2^(N−1) to 2^(N−1)−1.
To negate a value, invert its bits and add one at the same width. Inverting +3 (0011) gives 1100; adding one gives −3 (1101). Changing width also requires the appropriate sign extension.
Carry and overflow are different.
In four-bit signed arithmetic, 7+1 gives 1000, interpreted as −8. Two positive operands produced a negative result: signed overflow, even though there is no final carry.
For −1+1, 1111+0001 leaves 0000 in the low four bits. There is a carry, but the signed result 0 is correct. Align the signedness of ports and variables before arithmetic or comparison.
Try it yourself
Read four-bit 1000 as unsigned and signed.
Read the explanation
Unsigned: 8. Signed two’s complement: −8.