One's complement calculator

Enter bits to get their full inversion, a basic step in two's complement and in internet checksums.

Loading the tool…

Processing and privacy: The result is calculated inside your browser and your data is not sent to any server.

How to use it

  1. Enter binary number.
  2. The result appears straight away and updates as you edit.
  3. Copy the result, or copy a link that keeps the same values to share it.

How it is calculated

Every 0 becomes 1 and every 1 becomes 0 at the same width, so the result = (2 to the power n minus 1) minus the value. Two's complement = one's complement + 1, dropping any carry out.

Example

Inputs: Binary number = 00101010. Result: One's complement: 11010101.

00101010
11010101

Limits and caveats

  • Works on exactly the bits you type, so leading zeros change the result.
  • The decimal values shown are unsigned.

Questions about this tool

How is one's complement different from two's complement?

One's complement only flips the bits. Two's complement adds 1 to that and is what modern processors use.

Why do leading zeros matter?

Flipping 1010 gives 0101, but flipping 00001010 gives 11110101. The width is part of the operation.

Where is one's complement still used?

In the IPv4, TCP and UDP header checksums, which add words with one's complement addition and then invert the sum.