2
Complementsareusedindigitalcomputersinordertosimplythesubtractionoperationandforthelogical
manipulations.
FortheBinarynumber(base-2)system,therearetwotypesofcomplements:1’scomplementand2’s
complement.
1’s Complement of a Binary Number
Thereisasimplealgorithmtoconvertabinarynumberinto1’scomplement.Toget1’scomplementofa
binarynumber,simplyinvertthegivennumber.1.101010--010101
2’s Complement of a Binary Number
Thereisasimplealgorithmtoconvertabinarynumberinto2’scomplement.Toget2’scomplementofa
binarynumber,simplyinvertthegivennumberandadd1totheleastsignificantbit(LSB)ofgivenresult.
1.1110001110->0001110001 1’scomp
1->
0001110010
3
4
Subtractionsby1’sComplement:
Thealgorithmtosubtracttwobinarynumberusing1’scomplementisexplainedasfollowingbelow:
•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
Notethatsubtrahendisnumberthattobesubtractedfromtheanothernumber,i.e.,minuend.
Example(Case-1:WhenCarrybit1):
Evaluate10101–00101 00101from10101
Accordingtoabovealgorithm,
take1’scomplementofsubtrahend00101,whichwillbe11010,thenaddbothofthese.
So,10101+11010=101111.
Since,thereiscarrybit1,soaddthistotheLSBofgivenresult,
i.e.,01111+1=10000whichistheanswer.
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.
9
Subtractionby2’sComplement
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.
11 0 1 1 0 Minuend
10 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
(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
Additionby2’sComplement
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 inbinary 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 ⇒ 01 0 1 1
-0 1 0 1 ⇒ 11 0 1 1(2’s complement)
(Carry 1 discarded)00 1 1 0
Hence the sum is+ 00110.
12
Additionby2’sComplement
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 inbinary 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 ⇒ 00 0 1 1
-0 0 1 0 1 ⇒ 11 0 1 1(2’s complement) 11011
11 1 1 0 00001+1 =
00010
2’s complement of 1110 is (0001 + 0001) or 0010.
Hence the required sum is-00010.
13
Additionby2’sComplement
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 inbinary 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 ⇒ 11 1 0 1(2’s complement) 11100+1 = 11101
-0 0 1 0 1 ⇒ 11 0 1 1(2’s complement) 11010+1 = 11011
(Carry 1 discarded)111 0 0 0
2’s complement of 11000 is (00111 +1) or 01000.
Hence the required sum is –01000.