Ones Complement Calculator

Flip every bit in a binary number or calculate a fixed-width ones complement from a decimal integer.

Calculate a ones complement
Choose a binary or decimal input, then invert each bit from zero to one or one to zero.

About Ones Complement

The ones complement of a binary number is produced by reversing every bit: each zero becomes one and each one becomes zero. This operation is also called bit inversion or logical NOT. It is simple to perform by hand, yet it appears throughout computer architecture, digital electronics, network protocols, and the study of signed binary arithmetic. The calculator preserves the length of a binary input so that leading zeros and the intended register width remain visible in the answer. Bit width matters when a decimal integer is converted before inversion. The decimal value 42 is 101010 in its shortest binary form, but an eight-bit register stores it as 00101010. Inverting all eight positions gives 11010101, which is 213 when interpreted as an unsigned value. A different width creates a different pattern because additional leading zeros become leading ones. This tool therefore asks for a width from 1 through 32 whenever decimal mode is selected and rejects a number that cannot fit in that many unsigned bits. Historically, ones complement was also a signed-number representation. Positive values used ordinary binary, while a negative value was formed by inverting the positive value's bits. That system has two representations of zero: all zeros for positive zero and all ones for negative zero. Most modern processors instead use twos complement because it has one zero and makes arithmetic circuitry simpler. Even so, ones-complement arithmetic remains important in Internet checksums, where words are added with an end-around carry and the final sum is inverted. Do not confuse a ones complement with a twos complement. Twos complement is obtained by taking the ones complement and adding one within a fixed width. The distinction changes the represented negative value and is especially important when debugging low-level software. This calculator performs only the direct bit flip, reports the resulting bit sequence, and also displays its unsigned decimal interpretation. It is useful for checking homework, designing bit masks, studying logic gates, and confirming fixed-width conversions without manually scanning every position. For binary input, enter the exact sequence whose bits should be inverted. For decimal input, choose enough bits to hold the original number. The result panel shows the padded source bits, the inverted sequence, and the unsigned decimal value so every stage can be checked immediately.

Ones Complement Examples

InputOutputExplanation
Binary 10100101Each of the four positions is inverted.
Binary 0000111111110000Leading zeros are retained and become ones.
Decimal 42, 8 bits11010101 (213)42 is padded to 00101010 before inversion.

How to Calculate a Ones Complement

  1. Choose Binary input when you already have a bit sequence, or Decimal input when conversion is needed.
  2. Enter the binary sequence or a nonnegative decimal integer.
  3. For decimal input, select a bit width large enough to contain the number.
  4. Click Calculate ones complement to view the padded input, inverted bits, and decimal result.

Ones Complement FAQ

How do I find the ones complement of a binary number?

Replace every zero with one and every one with zero. Keep the same number of bits so the original width is preserved.

Why does bit width change the decimal-mode result?

Leading zeros are part of a fixed-width binary representation, and they become ones when inverted. An eight-bit inversion therefore differs from a sixteen-bit inversion of the same decimal value.

Is ones complement the same as twos complement?

No. Twos complement adds one to the ones-complement pattern within the chosen width, while ones complement only flips bits.

What is negative zero in ones-complement arithmetic?

An all-ones pattern represents negative zero in the historical signed ones-complement system. An all-zeros pattern represents positive zero, which is one reason most computers use twos complement instead.

Where is ones-complement arithmetic still used?

It is used in checksums for protocols such as IPv4, TCP, and UDP. The calculation adds fixed-width words with end-around carry and then inverts the final sum.