Ones Complement Calculator

Enter a binary number to flip its bits and get the one’s complement.

Result

11010011
8
44

How it is calculated

The one's complement of a binary number is made by inverting every bit: each 0 becomes 1 and each 1 becomes 0. The tool takes the digits exactly as typed, so the width is the number of characters you enter, and leading zeros are kept and flipped. It returns the flipped string, the bit count, and the decimal value of the original number, Σ bi × 2i, where bi is the bit at position i counted from the right. The decimal figure is computed with exact digit arithmetic, so even a 67-bit input of all ones shows 147,573,952,589,676,412,927. For an n-bit input the complement equals (2n − 1) − value. The input may contain only 0 and 1 and be at most 2048 digits long: spaces, a 0b prefix, other digits or an empty field give no result.

Worked example

Take the 8-bit number 00101100. Its decimal value is 32 + 8 + 4 = 44. Flip each bit in turn: 0→1, 0→1, 1→0, 0→1, 1→0, 1→0, 0→1, 0→1, which gives 11010011. Check with the formula: (28 − 1) − 44 = 255 − 44 = 211, and 11010011 in binary is 128 + 64 + 16 + 2 + 1 = 211. So the complement is 11010011, with 8 bits, from an original of decimal 44.

Try this example →

Common mistakes

  • Confusing one's complement with two's complement. Two's complement is the one's complement plus 1, so the two give different answers for every number.
  • Dropping the leading zeros. 00101100 and 101100 are different widths, and their complements, 11010011 and 010011, are different too.
  • Typing a prefix or separators such as 0b1011 or 1011 0010. Only the digits 0 and 1 are accepted, so remove them first or there is no result.
  • Entering a decimal number or hexadecimal digits. The input is read as binary only, so a value like 44 returns no result.
  • Treating the output as the negative of the number in everyday arithmetic. In a signed one's-complement system it represents the negative, but the tool only flips bits and does not interpret the sign.

About this calculator

The one's complement of a binary number is found by flipping every bit within a fixed width — every 0 becomes a 1 and every 1 becomes a 0. For example, the one's complement of the 8-bit value 00101100 is 11010011. This is different from two's complement, which is the one's complement plus 1, and which is what almost all modern processors actually use to represent negative numbers.

Older computer architectures, including some early mainframes and minicomputers, used one's complement directly to represent signed integers, which has the quirk of producing two different bit patterns for zero (positive zero and negative zero). One's complement arithmetic survives today mainly in the Internet checksum algorithm defined in RFC 1071, which computes IP, TCP and UDP header checksums using one's-complement addition specifically because it has useful properties for detecting bit errors and wraps around cleanly.

Was this helpful?

You can pick up to 3 reactions.

Comments

  • Be the first to comment.

Popular calculators

All Calculators