Binary Complement CalculatorFree online math calculator — instant results, no sign-up

Calculate fixed-width one's or two's complement of a binary word.

Inputs

Complement
11010010

Sign in to save results and favorites.

About the Binary Complement Calculator

The Binary Complement Calculator finds the fixed-width one's or two's complement of a binary word. It preserves the input's bit count, including leading zeros, and either flips every bit or flips every bit and adds one. With the default word 00101101 and One's selected, the complement is 11010010.

Binary word
The sequence of binary digits to complement, defaulting to 00101101, whose length defines the width in bits; the represented number is unitless.
Complement
The unitless choice of One's or Two's determines whether the calculator flips all bits only or also adds one, with One's selected by default.

Formula and method

Let x be the unsigned value of the input word and n its bit count. One's complement: C₁ = (2ⁿ − 1) − x. Two's complement: C₂ = (C₁ + 1) mod 2ⁿ = (−x) mod 2ⁿ. Write either result in binary using exactly n bits. For the default One's calculation: 11111111₂ − 00101101₂ = 11010010₂.
  • xThe unsigned integer value represented by the input binary word.
  • nThe number of digits in the input word, including leading zeros; the default word has 8 bits.
  • C₁The unsigned value of the fixed-width one's-complement result.
  • C₂The unsigned value of the fixed-width two's-complement result.
  • modThe remainder operation; modulo 2ⁿ keeps only the lowest n bits.
  • ₂A subscript indicating that a numeral is written in base two.

Count the input digits to establish the fixed width, then replace each 0 with 1 and each 1 with 0. This gives the one's complement. If Two's is selected, add one to that flipped word and discard any carry beyond the established width. For the default input 00101101 with One's selected, flipping the digits produces 11010010.

Worked example

These are the calculator's starting values and the results it actually produces for them.

Inputs

  • Binary word00101101
  • ComplementOne's

Results

  • Complement11010010

How to use the Binary Complement Calculator

  1. 1Enter 00101101 in Binary word to reproduce the default example, retaining both leading zeros.
  2. 2Check that the word contains only 0s and 1s; its eight digits establish an eight-bit result.
  3. 3Select One's in Complement for the default calculation, or Two's when you need bit inversion followed by adding one.
  4. 4Read the Complement result; for the default inputs it is 11010010.
  5. 5Verify the default result by checking that every output bit is the opposite of the input bit in the same position.

Reading your result

The Complement output row shows the resulting binary word at the same width as the input. In the default example, Complement = 11010010 is the eight-bit one's complement of 00101101. This row is a bit pattern, not automatically a signed decimal value; its numerical interpretation depends on whether you use unsigned, one's-complement signed, or two's-complement signed notation.

Limitations

The calculation assumes a nonempty word made only of binary digits. Leading zeros are significant because they establish width, and no extra sign bit is added. Two's-complement addition wraps within that width, discarding any final carry. Complementing bits does not by itself specify a signed-number encoding: one's complement has distinct positive and negative zero patterns, while two's complement has one zero pattern. In signed two's-complement arithmetic, negating the most negative representable value returns the same bit pattern because its positive counterpart cannot fit at that width.

Common questions

Why must I keep the leading zeros in 00101101?+

They make the input eight bits wide. The calculator complements those positions too, so the two leading zeros become the two leading ones in 11010010.

How does Two's differ from One's for this calculator?+

Both modes first flip every bit. One's stops there; Two's adds one to the flipped result and retains only the original number of bits.

Does 11010010 automatically represent a negative number?+

No. It is the output bit pattern. A leading 1 indicates a negative value only when the word is interpreted under an appropriate signed encoding; under unsigned interpretation, it is nonnegative.

Will complementing the result again recover my original word?+

Yes, if you keep the same width and use the same complement mode both times. Flipping twice restores every bit, and applying two's-complement negation twice also restores the original word modulo 2ⁿ.

Does the calculator save my information?+

Calculations run in your browser. While signed in, inputs and results are automatically recorded in account history; saving a result creates a separate saved record.

You might also like

Results are estimates for informational purposes and are not financial, medical or legal advice.