Learn all about complements in binary systems, including 1’s complement, 2’s complement, methods of representation, arithmetic operations, and applications in digital logic and computing.
Introduction to Complements in Binary Systems
In digital logic and computer arithmetic, complements play a critical role in simplifying subtraction, arithmetic operations, and error detection. A complement is a value that, when added to the original number, results in a specific standard value, such as all 1s or a fixed binary base.
Understanding 1’s complement and 2’s complement is essential for computer engineers, programmers, and students studying binary arithmetic and digital systems.
What is a Complement?
A complement of a number is a representation used to simplify arithmetic operations, particularly subtraction. Complements are widely used in digital computers because they allow subtraction to be performed as addition.
- 1’s Complement: Inverts all bits of the binary number.
- 2’s Complement: Add 1 to the 1’s complement of the number.
Types of Complements
1. 1’s Complement
Definition: The 1’s complement of a binary number is obtained by replacing all 0s with 1s and all 1s with 0s.
Example:
- Binary Number: 1010
- 1’s Complement: 0101
Characteristics of 1’s Complement:
- Used for sign representation of negative numbers.
- Easy to compute.
- Subtraction can be performed by adding the 1’s complement of the number.
Arithmetic using 1’s Complement:
- Add the original number and 1’s complement of the subtrahend.
- If there’s an end-around carry, add it to the least significant bit.
2. 2’s Complement
Definition: The 2’s complement of a binary number is obtained by adding 1 to its 1’s complement.
Example:
- Binary Number: 1010
- 1’s Complement: 0101
- 2’s Complement: 0101 + 1 = 0110
Characteristics of 2’s Complement:
- Most widely used method for signed number representation in computers.
- Allows direct subtraction using addition, without end-around carry.
- Simplifies arithmetic circuits in CPUs.
Advantages of 2’s Complement over 1’s Complement:
- Eliminates the end-around carry issue.
- Has a single representation for zero.
- Supports easier hardware implementation.
Representation of Signed Numbers Using Complements
| Method | Positive Number | Negative Number | Remarks |
|---|---|---|---|
| 1’s Complement | Same as binary | Invert all bits | Two zeros (+0 and -0) |
| 2’s Complement | Same as binary | 1’s complement +1 | Single zero representation |
Example: Represent -6 in 4-bit binary
- 6 in binary: 0110
- 1’s complement: 1001
- 2’s complement: 1010
Applications of Complements
- Binary Subtraction:
- Subtraction can be performed as addition of complements, simplifying hardware design.
- Signed Number Representation:
- 2’s complement is widely used in ALUs and digital processors for arithmetic operations.
- Error Detection:
- Complements are used in checksum and parity calculations in digital communication.
- Digital Logic Circuits:
- Helps in designing adders, subtractors, and combinational circuits.
Binary Arithmetic Using Complements
Subtraction Using 1’s Complement
Steps:
- Take the 1’s complement of the subtrahend.
- Add it to the minuend.
- If there is an end-around carry, add it to the sum.
Example: 7 – 5 using 4-bit numbers
- 7 = 0111, 5 = 0101
- 1’s complement of 5 = 1010
- Add: 0111 + 1010 = 10001
- End-around carry = 1 → 0001 + 1 = 0010 (Result = 2)
Subtraction Using 2’s Complement
Steps:
- Take the 2’s complement of the subtrahend.
- Add it to the minuend.
- Ignore carry beyond the most significant bit.
Example: 7 – 5 using 4-bit numbers
- 7 = 0111, 5 = 0101
- 2’s complement of 5 = 1011
- Add: 0111 + 1011 = 10010
- Ignore carry beyond 4 bits → 0010 (Result = 2)
Observation: 2’s complement simplifies subtraction without end-around carry.
Conclusion
Complements in binary systems are a fundamental concept in digital logic and computer arithmetic. Using 1’s and 2’s complements allows for efficient subtraction, signed number representation, and simpler hardware design. Mastery of complements is essential for computer engineers, programmers, and students to excel in digital electronics and computer architecture.
Call to Action:
Practice converting numbers into 1’s and 2’s complements and perform binary subtraction exercises to strengthen your understanding of digital arithmetic.
Frequently Asked Questions (FAQ)
1. What is the difference between 1’s and 2’s complement?
1’s complement inverts all bits, while 2’s complement adds 1 to the 1’s complement. 2’s complement simplifies subtraction by removing end-around carry.
2. Why is 2’s complement widely used?
Because it has a single zero representation, simplifies arithmetic circuits, and allows direct subtraction via addition.
3. How is subtraction performed using complements?
Subtraction is done by adding the complement of the subtrahend to the minuend. For 1’s complement, end-around carry is added; for 2’s complement, carry beyond MSB is ignored.
4. Can complements be used for fractional numbers?
Yes, using fixed-point or floating-point binary representation, complements can handle fractions.
5. Where are complements applied in digital systems?
Complements are used in ALUs, signed number arithmetic, error detection, and combinational circuits design.
