2. 2
Complements are used in digital computers in order to simply the subtraction operation and for the logical
manipulations.
For the Binary number (base-2) system, there are two types of complements: 1’s complement and 2’s
complement.
1’s Complement of a Binary Number
There is a simple algorithm to convert a binary number into 1’s complement. To get 1’s complement of a
binary number, simply invert the given number. 1. 101010 --010101
2’s Complement of a Binary Number
There is a simple algorithm to convert a binary number into 2’s complement. To get 2’s complement of a
binary number, simply invert the given number and add 1 to the least significant bit (LSB) of given result.
1. 1110001110 ->0001110001 1’s comp
1 ->
0001110010
4. 4
Subtractions by 1’s Complement:
The algorithm to subtract two binary number using 1’s complement is explained as following below:
•Take 1’s complement of the subtrahend
•Add with minuend
•If the result of above addition has carry bit 1, then add it to the least significant bit (LSB) of given result
•If there is no carry bit 1, then take 1’s complement of the result which will be negative
Note that subtrahend is number that to be subtracted from the another number, i.e., minuend.
Example (Case-1: When Carry bit 1):
Evaluate 10101 – 00101 00101 from 10101
According to above algorithm,
take 1’s complement of subtrahend 00101, which will be 11010, then add both of these.
So, 10101 + 11010 =1 01111 .
Since, there is carry bit 1, so add this to the LSB of given result,
i.e., 01111+1=10000 which is the answer.
5. 5
Example (Case-2: When no Carry bit):
Evaluate 11001 - 11110
According to above algorithm,
take 1’s complement of subtrahend 11110, which will be 00001.
Then add both of these, So, 11001 + 00001 =11010 .
Since there is no carry bit 1, so take 1’s complement of above result,
which will be 11010, and this is negative number, i.e, 00101, which is the answer.
6. 6
Additions by 1’s Complement:
There are difference scenario for addition of two binary numbers using 1’s complement. These are
explained as following below.
Case-1: Addition of positive and negative number when positive number has greater magnitude:
When positive number has greater magnitude, then take simply 1’s complement of negative number and
then add with the positive number, if there is any end-around carry of the sum then add the carry with
the least significant bit (LSB).
Example: Add 1110 and -1101. 1110 = E or 14 and 1101 = D or 13
So, take 1’s complement of 1101, which will be 0010, then add with given number. So, 1110+0010=1
0000 , then add this carry bit to the LSB, 0000+1=0001 , which is the answer.
7. 7
Additions by 1’s Complement:
There are difference scenario for addition of two binary numbers using 1’s complement. These are
explained as following below.
Case-2: Addition of positive and negative number when negative number has greater magnitude:
When the negative number has greater magnitude, then take 1’s complement of negative number
and add with given positive number. Since there will not be any end-around carry bit, so take 1’s
complement of the result and this result will be negative.
Example: Add 1010 and -1100 in five-bit registers. 10 +(– 12) = -2
Note that there are five-bit registers, so these new numbers will be 01010 and -01100.
Now take 1’s complement of 01100 which will be 10011 and add 01010+10011=11101 .
Then take 1’s complement of this result, which will be 00010 and this will be negative number, i.e., -
00010, which is the answer.
8. 8
Additions by 1’s Complement:
There are difference scenario for addition of two binary numbers using 1’s complement. These are
explained as following below.
Case-3: Addition of two negative numbers:
You need to take 1’s complement for both numbers, then add these 1’s complement of numbers.
Since there will always be end-around carry bit, so add this again to the LSB of result. Now, take 1’s
complement also of previous result, so this will be negative number.
Alternatively, you can add both negative number directly, and get this result which will be negative
only.
Example: add -1010 and -0101 in five bit-register. - 01010 = -10 and – 00101 = -5 = (-10)=(-5) = -15
These five bit numbers are -01010 and -00101.
Add complements of these numbers, 10101+11010 =1 01111 . Since, there is a carry bit 1, so add this
to the LSB of result, i.e., 01111+1=10000 . Now take the 1’s complement of this result, which will be
01111 and this number is negative, i.e, -01111, which is answer.
9. 9
Subtraction by 2’s Complement
The operation is carried out by means of the following steps:
(i) At first, 2’s complement of the subtrahend is found.
(ii) Then it is added to the minuend.
(iii) If the final carry over of the sum is 1, it is dropped and the result is positive.
(iv) If there is no carry over, the two’s complement of the sum will be the result and it is negative.
(i) 110110 - 010110
Solution:
The numbers of bits in the subtrahend is 5 while that of minuend is 6. We make the
number of bits in the subtrahend equal to that of minuend by taking a `0’ in the sixth
place of the subtrahend.
Now, 2’s complement of 010110 is (101001 + 1) i.e.101010. Adding this with the
minuend.
1 1 0 1 1 0 Minuend
1 0 1 0 1 0 2’s complement of subtrahend
Carry over 1 1 0 0 0 0 0 Result of addition
After dropping the carry over we get the result of subtraction to be 100000.
10. 10
(ii) 10110 – 11010
Solution:
2’s complement of 11010 is (00101 + 1) i.e. 00110. Hence
Minued - 1 0 1 1 0
2’s complement of subtrahend -0 0 1 1 0
Result of addition - 1 1 1 0 0
As there is no carry over, the result of subtraction is
negative and is obtained by writing the 2’s complement
of 11100 i.e.(00011 + 1) or Hence the difference is – 100.
00100.
(iii) 1010.11 – 1001.01
Solution:
2’s complement of 1001.01 is 0110.11. Hence
Minued - 1 0 1 0 . 1 1
2’s complement of subtrahend - 0 1 1 0 . 1
1
Carry over 1 0 0 0 1 . 1 0
After dropping the carry over we get the result of
subtraction as 1.10
11. 11
Addition by 2’s Complement
When negative numbers are expressed in binary addition using 2’s complement the addition of binary numbers
becomes easier. This operation is almost similar to that in 1’s complement system and is explained with examples
given below
A. Addition of a positive number and a negative number.
We consider the following cases.
Case I: When the positive number has a greater magnitude
In this case the carry which will be generated is discarded and the final result is the result of addition.
The following examples will illustrate this method in binary addition using 2’s complement:
In a 5-bit register find the sum of the following by using 2’s complement:
(i) 1011 and -0101 01011 & -00101 , 11010 +1 = 11011
Solution:
+ 1 0 1 1 ⇒ 0 1 0 1 1
- 0 1 0 1 ⇒ 1 1 0 1 1 (2’s complement)
(Carry 1 discarded) 0 0 1 1 0
Hence the sum is + 00110.
12. 12
Addition by 2’s Complement
Case II: When the negative number is greater.
When the negative numbers is greater no carry will be generated in the sign bit. The result of addition will be
negative and the final result is obtained by taking 2’s complement of the magnitude bits of the result.
The following examples will illustrate this method in binary addition using 2’s complement:
In a 5-bit register find the sum of the following by using 2’s complement:
(i) + 0 0 1 1 and - 0 1 0 1
Solution:
+ 0 0 0 1 1 ⇒ 0 0 0 1 1
- 0 0 1 0 1 ⇒ 1 1 0 1 1 (2’s complement) 11011
1 1 1 1 0 00001+1 =
00010
2’s complement of 1110 is (0001 + 0001) or 0010.
Hence the required sum is - 00010.
13. 13
Addition by 2’s Complement
Case III: When the numbers are negative.
When two negative numbers are added a carry will be generated from the sign bit which will be discarded. 2’s
complement of the magnitude bits of the operation will be the final sum.
The following examples will illustrate this method in binary addition using 2’s complement:
In a 5-bit register find the sum of the following by using 2’s complement:
(i) – 00011 and – 00101
Solution:
- 0 0 0 1 1 ⇒ 1 1 1 0 1 (2’s complement) 11100+1 = 11101
- 0 0 1 0 1 ⇒ 1 1 0 1 1 (2’s complement) 11010+1 = 11011
(Carry 1 discarded) 1 1 1 0 0 0
2’s complement of 11000 is (00111 +1) or 01000.
Hence the required sum is – 01000.