One's Complement Calculator

Enter a binary or decimal number and bit width to find its one's complement (all bits flipped) with step-by-step solution.

Enter Number

Result

One's Complement
--
binary

Step-by-Step Solution

What Is One's Complement?

One's complement is a method of representing signed integers in binary. To find the one's complement of a binary number, you simply flip (invert) every bit: change all 0s to 1s and all 1s to 0s. This operation is also known as the bitwise NOT operation.

How One's Complement Works

Bit Flipping

Every 0 becomes 1, and every 1 becomes 0.

NOT 10110011 = 01001100

Decimal Equivalent

For an n-bit number N, the one's complement equals (2^n - 1) - N.

(2^n - 1) - N

Signed Representation

In one's complement, the MSB indicates sign: 0 = positive, 1 = negative.

MSB = 0 (positive), MSB = 1 (negative)

One's Complement vs Two's Complement

One's complement has a notable drawback: it has two representations for zero (+0 as 00000000 and -0 as 11111111). Two's complement solves this by adding 1 to the one's complement, giving a unique zero representation. Modern computers primarily use two's complement, but one's complement is still important in networking (e.g., IP checksum calculations).

Range of Values

For an n-bit one's complement system, the range of representable values is from -(2^(n-1) - 1) to +(2^(n-1) - 1). For example, an 8-bit one's complement system can represent values from -127 to +127.

Applications

  • Internet Protocol (IP) header checksums use one's complement arithmetic.
  • Some older computer architectures used one's complement for signed integer arithmetic.
  • Bitwise NOT operations in programming languages perform one's complement.
  • Error detection and correction codes may use one's complement operations.