To negate a twos complement number, turning x into −x:
- Write x at the full width, including leading zeros.
- Invert every bit (0 ↔ 1). This is the ones complement.
- Add 1.
+6 in 8 bits: 00000110 → 11111001 → 11111010 = −6. The same steps take −6 back to +6.
Why it works: x plus its inverted copy has no carries and gives all 1s, which is −1. So inverted x = −1 − x, and adding 1 gives −x.
A shortcut by hand: copy the bits from the right up to and including the first 1, then invert everything to its left. For 00101100, keep 100 and invert 00101 to 11010, giving 11010100.
One value has no positive partner. The most negative number, −2ⁿ⁻¹, negates to itself: in 8 bits, 10000000 → 01111111 → 10000000. +128 doesn't fit, so this is signed overflow.
In hardware, negation is built into the adder subtractor: XOR gates invert B, and the carry-in supplies the +1.