binary complement calculator

Accepts only 0 and 1. Spaces, underscores, and optional 0b prefix are allowed.
If provided, the binary input is left-padded with zeros to match this width.

What this binary complement calculator does

This calculator computes both the one's complement and two's complement of a binary number. It is useful for students learning digital logic, programmers working with signed integers, and engineers debugging low-level systems.

Enter a binary value, optionally set a bit width, and click calculate. You will get:

  • Normalized binary input
  • One's complement (bit inversion)
  • Two's complement (inversion + 1)
  • Unsigned and signed decimal interpretations

Binary complement basics

One's complement

One's complement is created by flipping every bit: 0 → 1 and 1 → 0. For example, for 8 bits:

00101101 → 11010010

Two's complement

Two's complement is the one's complement plus one, keeping the same bit width. This is the most common representation for signed integers in modern computers.

00101101 → 11010010 + 1 = 11010011

Tip: Two's complement depends on bit width. The same binary digits can represent different values in 4-bit, 8-bit, or 16-bit systems.

How to use the calculator

  1. Type your binary number (for example, 111001).
  2. Optionally enter a bit width such as 8 or 16.
  3. Click Calculate Complements.
  4. Review the output table for complements and decimal values.

Worked examples

Example 1: Positive-looking binary

Input: 00101101 (8-bit)
One's complement: 11010010
Two's complement: 11010011

Example 2: All zeros

Input: 00000000
One's complement: 11111111
Two's complement: 00000000 (overflow carry is dropped)

Example 3: Width changes meaning

Input digits: 1011
As 4-bit signed, this represents -5.
As 8-bit with padding (00001011), it represents 11.

Why two's complement is preferred

  • Only one representation for zero
  • Simpler hardware for addition and subtraction
  • Natural overflow behavior modulo 2ⁿ
  • Standard in most CPUs and programming languages

Common mistakes to avoid

  • Forgetting to specify bit width when a problem requires fixed-length values.
  • Mixing one's complement and two's complement in the same calculation.
  • Interpreting binary as signed when your context is unsigned (or vice versa).
  • Not dropping the overflow bit after adding 1 in two's complement.

Quick FAQ

Is this the same as a binary negation calculator?

One's complement is bitwise negation. Two's complement is the arithmetic negation of a value within a fixed width.

Can I paste numbers with spaces?

Yes. Inputs like 1010 1100 or 1010_1100 are accepted and normalized.

What if my width is larger than my number?

The calculator pads with leading zeros before computing complements.

🔗 Related Calculators