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.
Input
Result
Enter a value, then press Calculate.
How one's complement works
- Negate: to get the negative of a number, invert every bit. There is no add-one step, which is the difference from two's complement. 5 = 00000101, so -5 = 11111010.
- Range: with n bits you can store -(2n-1-1) to 2n-1-1 (8-bit: -127 to 127). The leading bit is 1 for negative numbers.
- Two zeros: 00000000 is +0 and 11111111 is -0. They compare equal as numbers but are different bit patterns, which is why two's complement replaced one's complement for integer hardware.
- End-around carry: add the two patterns as unsigned numbers; if a carry comes out of the top bit, add that 1 back into the bottom bit.
- Subtract: A − B is A plus the inverse of B.
- Overflow: the exact result does not fit the range. It happens when two numbers with the same sign give an answer with the other sign.
Worked examples
| Question | Working | Answer |
|---|---|---|
| -5 in 8 bits | 00000101 inverted | 11111010 |
| 7 + (-3) in 4 bits | 0111 + 1100 = 1 0011, carry 1 added back | 0100 = 4 |
| 5 + (-5) in 8 bits | 00000101 + 11111010 = 11111111, no carry | 11111111 = 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.