DEV Community

Binary One’s Complement
Binary One’s Complement

Posted on

Binary One’s Complement: Definition, Formula, and Examples

Binary One’s Complement is an important concept in computer science and digital electronics. It is a method of obtaining the complement of a binary number by changing every 0 to 1 and every 1 to 0. This simple operation is useful in binary arithmetic, digital logic, and the historical representation of signed integers in computers.

Understanding one’s complement makes it easier to learn two’s complement, binary subtraction, and how computers represent positive and negative numbers.

What Is Binary One’s Complement?

One’s complement is the result of inverting every bit in a binary number. A binary number uses only two digits: 0 and 1. To calculate its one’s complement, replace each digit with its opposite.

0 becomes 1.
1 becomes 0.

For example, the one’s complement of 101100 is 010011. Every bit changes, but the total number of bits remains the same. citeturn680978search1turn680978search13

Formula for One’s Complement

For an (n)-bit binary number (B), its one’s complement can be expressed as:

[
\text{One's Complement}=(2^n-1)-B
]

Here, (n) represents the number of bits, and (B) represents the unsigned decimal value of the binary number.

The formula expresses the same operation as flipping every binary digit.

How to Calculate One’s Complement

Follow these simple steps:

Write the binary number.
Identify each 0 and 1.
Change every 0 to 1.
Change every 1 to 0.
Write the resulting binary number using the same number of bits.
Example 1: Find the One’s Complement of 1010

Original binary number:

1010

Invert every bit:

1 becomes 0.
0 becomes 1.
1 becomes 0.
0 becomes 1.

Result:

One’s Complement = 0101

Example 2: Find the One’s Complement of 110101

Original number: 110101

After inverting all bits:

110101 → 001010

Therefore, the one’s complement is 001010.

Example 3: Find the One’s Complement of 00011100

Original number: 00011100

After changing every 0 to 1 and every 1 to 0:

00011100 → 11100011

Therefore, the answer is 11100011.

One’s Complement Conversion Table
Original Binary One’s Complement
0000 1111
0001 1110
0010 1101
0011 1100
0100 1011
0101 1010
1010 0101
1100 0011
1111 0000

The table shows how each bit is inverted to produce the corresponding complement.

Difference Between One’s Complement and Two’s Complement

One’s complement and two’s complement are related binary arithmetic concepts, but they are not identical.

Feature One’s Complement Two’s Complement
Calculation Invert every bit Invert every bit and add 1
Example for 0101 1010 1011
Zero representation Has positive and negative zero Has only one zero
Modern computer use Limited and mostly historical Widely used for signed integers

Two’s complement is generally preferred in modern computer systems because it provides a single representation of zero and simplifies signed arithmetic. citeturn680978search12turn680978search4

Applications of Binary One’s Complement

One’s complement has several educational and technical applications.

  1. Binary Arithmetic

One’s complement helps students understand how binary numbers can be inverted and how complement-based arithmetic works.

  1. Representing Negative Numbers

In a one’s-complement signed-number system, a negative number is represented by inverting the bits of its positive counterpart. For example, in a 4-bit system, positive six is 0110, while negative six is 1001.

  1. Digital Electronics

Bit inversion is a basic operation in digital logic circuits. Understanding one’s complement helps explain NOT operations and related digital circuit behavior.

  1. Learning Computer Number Systems

One’s complement provides a foundation for understanding two’s complement, signed binary numbers, and other number-representation methods.

Advantages and Limitations

Advantages:

Easy to calculate by flipping bits.
Helps explain binary logic and complement arithmetic.
Provides a useful foundation for learning signed number representations.

Limitations:

It represents zero in two ways: positive zero and negative zero.
Arithmetic may require an end-around carry.
It is less commonly used than two’s complement for signed integers in modern computers. citeturn680978search4turn680978search12
Frequently Asked Questions
What is the one’s complement of a binary number?

It is the binary number obtained by changing every 0 to 1 and every 1 to 0.

What is the one’s complement of 10101?

The answer is 01010.

Is one’s complement the same as two’s complement?

No. One’s complement flips every bit, while two’s complement flips every bit and then adds one.

Why is one’s complement important?

It helps explain binary arithmetic, signed number representation, and fundamental operations in digital electronics.

Conclusion

Binary One’s Complement is a simple but important concept in computer science. By inverting every bit in a binary number, you can calculate its one’s complement quickly and accurately. Although modern computers generally use two’s complement for signed integers, learning one’s complement remains valuable for understanding binary arithmetic, digital logic, and computer number systems.

Top comments (0)