Free Binary Calculator

One's Complement Calculator

Calculate the one's complement of a binary number, convert signed decimal integers into one's-complement representation, and decode binary patterns. Choose a bit width, inspect every bit, and follow the calculation steps instantly.

Calculate One's Complement

Results are calculated locally in your browser. Your input is not sent to a server.

8-bit one's-complement range: -127 to +127, with two zero representations.
Enter a whole number within the selected signed range. Enter -0 to inspect the negative-zero representation.

What Is One's Complement?

One's complement, also written as 1's complement or ones' complement, is a binary operation that changes every zero to a one and every one to a zero. It is also a historical method for representing positive and negative integers in digital systems.

For example, the 8-bit binary number 00000101 represents positive five. Flipping all eight bits gives 11111010, which represents negative five in an 8-bit one's-complement system.

How to Calculate One's Complement

  1. Choose the number of bits, such as 8 or 16.
  2. Write the input as a binary pattern with the chosen width.
  3. Replace every 0 with 1 and every 1 with 0.
  4. Read the resulting pattern or interpret it as a signed value.
00000101 → 11111010
01010101 → 10101010
11110000 → 00001111

One's-Complement Decimal Conversion

For a positive integer, the one's-complement representation is its ordinary binary form padded to the selected width, with a zero as the most significant bit. For a negative integer, first convert its absolute value to binary and then invert every bit.

In an 8-bit system, positive five is 00000101. Negative five is formed by inverting those bits: 11111010. To decode that negative pattern, invert it again to get 00000101, whose magnitude is five, and apply the negative sign.

One's-Complement Examples

Decimal input 8-bit binary One's-complement encoding
+5 00000101 00000101
-5 00000101 (magnitude) 11111010
+42 00101010 00101010
-42 00101010 (magnitude) 11010101
+0 00000000 00000000
-0 00000000 (magnitude) 11111111

Understanding the Sign Bit

In one's-complement signed representation, the most significant bit indicates the sign. A leading zero indicates a non-negative value. A leading one indicates a negative value, including the special negative-zero pattern consisting entirely of ones.

For an n-bit value, the signed range is -(2^(n-1)-1) through +(2^(n-1)-1). For example, an 8-bit one's-complement integer ranges from -127 to +127. There is no representation for -128 in an 8-bit one's-complement system.

One's Complement vs. Two's Complement

Feature One's complement Two's complement
Negative encoding Invert all bits Invert all bits and add one
Zero Positive zero and negative zero One zero representation
8-bit signed range -127 to +127 -128 to +127
Modern use Historical representation; also relevant to one's-complement arithmetic and checksums Common signed integer representation in modern processors

One's-complement arithmetic is also important in checksum calculations. In one's-complement addition, any carry beyond the most significant bit is wrapped around and added to the low-order bits. This is distinct from simply flipping bits and is why one's complement and two's complement should not be treated as interchangeable.

Frequently Asked Questions

1. What is the one's complement of a binary number?

It is the bit pattern obtained by reversing every bit: each zero becomes one and each one becomes zero. For example, 10110010 becomes 01001101.

2. How do I find the one's complement of a decimal number?

Select decimal mode and a bit width. Enter a signed integer. For a negative number, the calculator converts its magnitude to fixed-width binary and flips every bit to produce the encoding.

3. Why are there two zeros in one's complement?

The all-zero bit pattern represents positive zero, while the all-one pattern represents negative zero. Both patterns represent zero numerically, but their bit patterns are different.

4. What is the 8-bit one's complement range?

The range is -127 to +127. An 8-bit one's-complement system has two zero representations, so it cannot represent -128.

5. Is one's complement the same as two's complement?

No. One's complement flips all bits. Two's complement flips all bits and adds one. Two's complement has a single zero and is the usual signed integer representation in modern computer hardware.

6. Can I use this calculator for 64-bit values?

Yes. The calculator uses JavaScript's BigInt for integer arithmetic, so 64-bit values are handled without the precision loss that can occur with ordinary JavaScript numbers.

More Binary Conversion Tools

Continue working with binary numbers using these related calculators.