Developer Tools

One's complement.

Invert a binary number, convert signed decimal to one's complement and back, or add and subtract with end-around carry. 4, 8, 16, 32 and 64 bits, exact BigInt maths. Runs in your browser.

Advertisement

Input

Result

Enter a value, then press Calculate.

How one's complement works

Worked examples

QuestionWorkingAnswer
-5 in 8 bits00000101 inverted11111010
7 + (-3) in 4 bits0111 + 1100 = 1 0011, carry 1 added back0100 = 4
5 + (-5) in 8 bits00000101 + 11111010 = 11111111, no carry11111111 = negative zero

Where it is used

The Internet checksum used by IP, TCP and UDP is a 16-bit one's complement sum, computed with end-around carry (RFC 1071). Older mainframes also stored integers this way. Everyday CPUs use two's complement; for plain base conversion see the Binary Converter, and for add, subtract, multiply and divide with column working see the Binary Calculator.

Everything runs in your browser using BigInt, so 64-bit values are exact. Nothing is sent anywhere.

FAQ

What is the one's complement of a binary number?

Flip every bit: each 0 becomes 1 and each 1 becomes 0. For example, the one's complement of 00000101 is 11111010.

What is the difference between one's complement and two's complement?

Two's complement is one's complement plus 1. One's complement has two zeros (+0 and -0) and needs an end-around carry when adding; two's complement has one zero and an extra negative value (-128 in 8 bits).

Why does one's complement have a negative zero?

Inverting 00000000 gives 11111111. That pattern has a 1 sign bit and magnitude zero, so it reads as -0. It equals 0 numerically but is a different bit pattern.

What is end-around carry?

When adding two one's complement numbers, a carry out of the top bit is added back into the lowest bit of the sum. Without this step, results involving negative numbers are off by one.

What range does an 8-bit one's complement number have?

-127 to 127. There is no -128, because the all-ones pattern is negative zero rather than a separate value.

Sources

Sources retrieved October 2026.

Advertisement
Advertisement