Why the Bit Width Matters
A computer stores integers in a fixed number of bits, such as 8 or 32. Two’s complement works within that width: to encode a negative value, invert every bit of its positive counterpart and add one, keeping the result to the same number of bits.
For example, in 8 bits, positive 5 is `00000101`. Inverting the bits gives `11111010`; adding one produces `11111011`, the representation of −5.
One Addition Circuit, Two Jobs
The clever part is what happens next. The processor can add two’s-complement numbers using the same basic binary addition it uses for positive numbers. Add 5 and −5:
`00000101 + 11111011 = 1 00000000`
The extra leftmost carry falls outside the 8-bit result, leaving `00000000`. The same operation handles subtraction: subtracting a value can be done by adding its negative representation. This avoids needing a separate set of arithmetic rules or hardware just for negative numbers.
A Range With a Built-In Tradeoff
With 8 bits, the representable integers run from −128 to 127. One bit pattern stands for zero, so there is no separate “negative zero,” and the available range has one more negative value than positive values. If a calculation goes beyond the range, the fixed-width result wraps around; that is called overflow, and it must be handled when it matters.
The practical payoff is simple: the same bit patterns and addition machinery support both ordinary addition and subtraction, as long as the numbers fit the chosen width.






