In digital logic, complements are used to perform logical operations, especially the subtraction operation. The binary number system contains two types of complements:
1's complement
2's complement
Complements make it possible for computers to perform subtraction using only addition circuits. This simplifies the design of the computer's arithmetic logic unit (ALU).
Definition
1's Complement: The 1's complement of a binary number is obtained by toggling (inverting) all its bits. That means we transform every 1 bit into a 0 bit and every 0 bit into a 1 bit.
2's Complement: The 2's complement of a binary number is obtained by taking the 1's complement of the number and then adding 1 to the least significant bit (LSB).
Main Idea
Computers use complements to perform subtraction. Instead of building separate circuits for subtraction, computers use addition circuits along with complements. This is more efficient and simpler to implement in hardware.
Core Concept
1's Complement
The binary numbers can be easily converted into the 1's complement with the help of a simple technique. According to this algorithm, if we toggle or invert all bits of a binary number, the generated binary number will become the 1's complement of that binary number. That means we have to transform 1 bit into the 0 bit and 0 bit into the 1 bit in the 1's complement.
2's Complement
The binary numbers can be converted into the 2's complement with the help of a very simple technique:
Take the 1's complement of the binary number.
Add 1 to the LSB (least significant bit).
Detailed Explanation
Example 1: 2's complement of binary number 01010001
Step 1: Write the number.
01010001 (Number)
Step 2: Take the 1's complement (invert all bits).
Computers can only add, not subtract, at the hardware level. So to subtract A - B, the computer actually calculates A + (2's complement of B).
The 2's complement is preferred over the 1's complement because it eliminates the problem of having two representations for zero (+0 and -0). In 1's complement, 0000 (+0) and 1111 (-0) both represent zero, which is inefficient.
2's complement also simplifies arithmetic because the carry out of the MSB can simply be ignored.
Range of 8-bit numbers in 2's complement:
-128 to +127
Important Points
- 1's complement = invert all bits.
- 2's complement = 1's complement + 1.
- Complements are used for binary subtraction.
- 2's complement is preferred in modern computers.
- 2's complement has only one representation for zero.
- 8-bit 2's complement range: -128 to +127.
- The sign bit is the MSB (0 = positive, 1 = negative).
Remember
- 1's complement: toggle all bits.
- 2's complement: toggle all bits, then add 1.
- 2's complement of 01010001 = 10101111.
- 2's complement of 10101110 = 01010010.
- 2's complement is used to represent negative numbers.
- 2's complement of a number gives back the original number.
Common Mistakes
- Forgetting to add 1 after taking the 1's complement.
- Adding 1 to the wrong end (must add to the LSB, which is the rightmost bit).
- Confusing 1's complement with 2's complement.
- Forgetting to invert all bits before adding 1.
- Thinking that the 2's complement of a positive number is always negative (it depends on the number of bits and interpretation).
- Making errors in binary addition when adding 1.
Quick Revision
1's complement: invert all bits (0→1, 1→0).
2's complement: 1's complement + 1.
Used for binary subtraction.
2's complement is standard in modern computers.
Unique zero representation in 2's complement.
Range: -2n-1 to 2n-1 - 1.
60-Second Revision
1's complement = flip all bits.
2's complement = flip all bits, then add 1.
Complements allow subtraction using addition.
2's complement has one zero, no +0/-0 confusion.
MSB is the sign bit.
Warning: Always add 1 to the LSB, not the MSB.
Did you understand this topic?
Your answer is saved with your learning record. It does not mark the topic as mastered.
Quick revision
Revision Zone
Review the key facts, formulas and checks before you move on.
1.2.5 Compliments (1's and 2's)
Sticky Notes · Quick Revision
1.
Key Point 1
1's complement = flip bits.
2.
Key Point 2
2's complement = flip bits + 1.
3.
Key Point 3
2's complement used for subtraction.
4.
Key Point 4
8-bit 2's complement range: -128 to 127.
5.
Key Point 5
MSB = sign bit.
6.
Key Point 6
2's complement of 2's complement = original number.