Skip to content
BetterDL

Two's complement negation

Also called: negation, invert and add 1, negate, taking the two's complement

Changing the sign of a two's complement number by inverting every bit and then adding 1. It works in both directions, from + to − and back.

To negate a twos complement number, turning x into −x:

  1. Write x at the full width, including leading zeros.
  2. Invert every bit (0 ↔ 1). This is the ones complement.
  3. 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.

1
−128
1
64
0
32
1
16
0
8
1
4
0
2
0
1

Worked examples

Example

Write −44 in 8 bits

Invert, then add 1.

  1. 1.

    +44 = 00101100.

  2. 2.

    Invert: 11010011.

  3. 3.

    Add 1: 11010100.

  4. 4.

    Check with weights: −128 + 64 + 16 + 4 = −44.

Example

Decode 11100110 by negating

The MSB is 1, so the value is negative. Its size is what you get by negating it.

  1. 1.

    Invert: 00011001.

  2. 2.

    Add 1: 00011010 = 16 + 8 + 2 = 26.

  3. 3.

    So 11100110 is −26. Check: −128 + 64 + 32 + 4 + 2 = −26.

Common mistakes

  • Inverting before padding to the full width. The leading zeros must be inverted too.

  • Forgetting the +1, which leaves the one's complement (one too small).

  • Adding 1 before inverting. That gives −x − 2.

  • Expecting −128 to negate to +128 in 8 bits.

Practice Two's complement negation

Interactive questions with instant feedback and a worked solution for every wrong answer.

Learn it step by step

Two's complement negation is taught in Number Systems and Adders and ALUs.