Quiz Entry - updated: 2026.07.07
How does two's complement encoding represent signed integers?
Same as unsigned, except the top bit's weight is negative (−2^{w−1}); so MSB = 0 is positive and MSB = 1 is negative.
* Each bit keeps its positional weight, but the top (sign) bit's weight is negative: for 4 bits it is −2³ = −8, so 1011 sums to −8 + 2 + 1 = −5. *
B2T(X) = -x_{w-1} × 2^{w-1} + Σ(x_i × 2^i) for i from 0 to w-2
Example (4 bits):
Binary: 1011
Value: -1×2³ + 0×2² + 1×2¹ + 1×2⁰
= -8 + 0 + 2 + 1 = -5
Key properties:
- MSB = 0 → positive (same as unsigned)
- MSB = 1 → negative
- Range: -2^{w-1} to 2^{w-1} - 1
Intuitive understanding:
- Think of the MSB as contributing -8 (for 4-bit) instead of +8
- The other bits add positive values to this negative base
1000= -8 + 0 = -8 (most negative)1111= -8 + 4 + 2 + 1 = -1 (least negative)0111= 0 + 4 + 2 + 1 = +7 (most positive)
Tip: The sign bit's "weight" is -2^{w-1}, not just a flag. This is why the math works!
Go deeper:
Two's complement (Wikipedia) — the standard signed-integer encoding, its arithmetic, and the sign-bit weight.