Skip to content
BetterDL

One's complement

Also called: 1's complement, ones' complement

The result of inverting every bit of a binary number. As a signed format it represents −x as the inverse of x; adding 1 turns it into the two's complement.

The one's complement of a binary number is what you get by flipping every bit: each 0 becomes 1 and each 1 becomes 0. 0101 → 1010.

It matters in two ways.

As a step. One's complement is half of twos complement negation. For any n-bit x, inverting gives (2ⁿ − 1) − x, which as a two's complement value is −x − 1. Add 1 and you have −x. In an adder subtractor, the XOR controlled inverters on B produce the one's complement, and the carry-in C0 = 1 adds the missing 1. Forget the carry-in and every difference comes out one too small.

As a format. Some early computers stored negative numbers this way, so −5 in 4 bits was 1010. Like sign magnitude, it has two zeros (0000 and 1111), and addition needs an extra correction step. Modern integer hardware uses twos complement instead.

The name means "complement with respect to all 1s": subtracting x from 11…1 never needs a borrow, and the result is every bit of x flipped.

1
−8
0
4
0
2
1
1

Worked examples

Example

One's vs two's complement of 6 (4 bits)

6 = 0110.

  1. 1.

    One's complement: 1001. As a two's complement value that's −8 + 1 = −7.

  2. 2.

    Two's complement: 1001 + 1 = 1010 = −6.

  3. 3.

    The one's complement is always exactly one less than −x.

Example

The missing +1 in a subtractor

A circuit inverts B but leaves C0 = 0, and computes 1001 − 0011 (9 − 3).

  1. 1.

    Inverted B: 1100.

  2. 2.

    1001 + 1100 = 1 0101. Keep 4 bits: 0101 = 5.

  3. 3.

    The right answer is 6. With C0 = 1, the sum is 0110 = 6.

Common mistakes

  • Calling the one's complement −x. In two's complement terms it's −x − 1.

  • Building a subtractor with only XOR inverters and leaving C0 = 0.

  • Thinking the one's complement format has one zero. It has two.

Practice One's complement

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

Learn it step by step

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