How to use the Binary One's complement Converter tool
- Type the word into the Binary digits box and include any leading zeros that belong to its width.
- Select Convert to invert all of the bits at once.
- Read the one's complement in the Result box. It is printed as one unbroken run of bits.
- Select Copy to take the value, or Example to try the sample word 01001101.
How one's complement works
The one's complement of a word is the bitwise NOT of that word. Arithmetically, for a word of n bits it equals (2^n - 1) minus the value, because subtracting from a row of ones never needs a borrow. For the 8-bit sample, 01001101 is 77 and the result 10110010 is 178, and 77 + 178 = 255.
As a signed number system, one's complement stores a negative number as the inversion of the positive one. An 8-bit word then covers -127 to +127 and has two zeros: 00000000 and 11111111. Adding needs an end-around carry, where a carry out of the top bit is added back at the bottom.
01001101 -> 10110010
0000 1111 -> 11110000
0b1010 -> 0101Word width decides the answer
The tool has no width setting. It inverts exactly the digits you type, so leading zeros change the result. The value thirteen entered as 1101 becomes 0010, but entered as an 8-bit word 00001101 it becomes 11110010. Decide the register or field size first and pad the input to that length.
Spaces, tabs and line breaks are dropped before the flip and are not put back, and a single 0b prefix at the start is removed. Anything other than 0 and 1, or more than 65,536 bits, produces the message: Enter between 1 and 65,536 binary digits.
Where one's complement is still used
Processors moved to two's complement decades ago, but one's complement arithmetic is in every IP packet. The Internet checksum described in RFC 1071 adds 16-bit words with end-around carry and stores the one's complement of the sum. IPv4 headers, TCP, UDP and ICMP all carry that field.
Inversion is also the first half of negating a two's complement number: flip the bits, then add one. And it is how you build a clear mask from a set mask, for example turning 00001000 into 11110111 before an AND.
One's complement next to related tools
The Bitwise NOT Calculator returns the same bits for a single input. The Binary Two's complement Converter goes one step further and adds one, which gives the pattern modern CPUs use for negative integers. If you want to know what a pattern means as a signed number in two's complement, use the Binary Signed unsigned Converter.
Frequently asked questions
How do you find the one's complement of a binary number?
Replace every 0 with 1 and every 1 with 0, keeping the same number of digits. For 01001101 that gives 10110010. No carries or borrows are involved, so each bit can be handled on its own.
What is the difference between one's complement and two's complement?
Two's complement is the one's complement plus one. One's complement has both a positive and a negative zero and needs an end-around carry when adding. Two's complement has a single zero and adds with an ordinary binary adder.
Why do leading zeros change the result?
Each leading zero is a bit, and inversion turns it into a 1. The pattern 0101 becomes 1010, while 00000101 becomes 11111010. Enter the full width of the register you are modeling.
What is negative zero in one's complement?
It is the all-ones pattern. Inverting 00000000 gives 11111111, which a one's complement machine treats as zero with a minus sign. UDP makes use of it: a computed checksum of zero is transmitted as all ones, because all zeros in that field means no checksum was calculated.
Does the result keep the spaces from my input?
No. Whitespace is removed before the bits are inverted, so 0000 1111 returns 11110000 as a single group. Add your own grouping after copying if you need it.