radixflip

1's and 2's Complement

Type a binary number — every bit flip, the +1 addition with its carries, and the signed value update live.

Find the Complement

Bitwise calculator →  ·  Logic gates →

How to find the 2's complement

  1. Write the number in fixed width. Pad with leading zeros to the chosen bit width, for example 0110 in 4 bits.
  2. Flip every bit. Change each 0 to 1 and each 1 to 0. This is the 1's complement: 0110 becomes 1001.
  3. Add 1. Add 1 to the flipped number, carrying from right to left. 1001 + 1 = 1010.
  4. Read the signed value. If the leftmost bit is 1, the result is negative. 1010 in 4-bit signed form means −6.

What 1's and 2's complement are for

1's complement flips every bit. It is a simple idea, but it has a flaw: it has two zeros. Flipping 0000 gives 1111, so +0 and −0 are different patterns, which makes comparisons and arithmetic awkward.

2's complement flips every bit and adds 1. That single change fixes the double zero — only 0000 means zero — and it makes subtraction work as addition: to compute A − B, add the 2's complement of B to A and discard any carry out of the leftmost bit. That is why every modern processor stores signed integers in 2's complement.

The leftmost bit is the sign bit: 1 means negative, 0 means zero or positive. To read a negative value, take the 2's complement again to get its magnitude, then add a minus sign. The 2's complement of 1010 is 0110, which is 6, so 1010 means −6.

Worked example: 5 − 3 in 4 bits

3 is 0011. Its 1's complement is 1100, and adding 1 gives the 2's complement 1101, which means −3. Then 5 − 3 becomes 5 + (−3):

StepBitsValue
501015
300113
Flip the bits of 311001's complement
Add 11101−3
Add: 0101 + 110110010Discard the carry → 0010
Result00102

The carry out of the leftmost column is discarded — that is part of the method, not an error.

Signed ranges

BitsSmallestLargest
4−8 (1000)+7 (0111)
8−128 (10000000)+127 (01111111)
16−32,768+32,767

Frequently asked questions

What is the difference between 1’s complement and 2’s complement?

1’s complement flips every bit: 0 becomes 1 and 1 becomes 0. 2’s complement flips every bit and then adds 1. The extra +1 is what makes 2’s complement the standard way to represent negative numbers — it gives exactly one zero and makes subtraction work as addition.

Why does 1’s complement have two zeros?

In 1’s complement, flipping all bits of 0000 gives 1111, and both patterns mean zero: +0 is 0000 and −0 is 1111. That double zero complicates comparisons and arithmetic, which is why computers use 2’s complement instead, where only 0000 means zero.

How do I find the 2’s complement of a binary number?

Flip every bit, then add 1. Example: 0110 (6) flips to 1001, and 1001 + 1 = 1010. In 4-bit signed form, 1010 means −6. Try it above: type 0110, pick 4 bits, and watch each step.

How do I subtract using 2’s complement?

To compute A − B, add the 2’s complement of B to A and discard any carry out of the leftmost bit. Example in 4 bits: 5 − 3 becomes 0101 + 1101 = 10010; discarding the carry gives 0010, which is 2. Subtraction becomes addition, which is simpler hardware.

What range of numbers can 8-bit 2’s complement hold?

From −128 to +127. In general, N-bit 2’s complement covers −2^(N−1) to 2^(N−1) − 1: 4 bits give −8 to +7, 8 bits give −128 to +127, and 16 bits give −32,768 to +32,767. The leftmost bit is the sign bit: 1 means negative, 0 means zero or positive.

Bitwise calculator →  ·  Binary calculator →