There are two types of complements. They are :-
1. Radix complement
2. Diminished Radix complement
NOTE:-
- The diminished radix complement is known as “(r-1)’s” complement.
- The radix complement is known as “r’s” complement.
- In binary number system the base is 2. Therefore, if we placed 2 in r then, we get 1’s and 2’s complements.
- In decimal number system the base is 10. If we place 10 in r then we get 9’s and 10’s complements.
=>1’s complement
:-
1. The 1’s
complement can be obtained by subtracting the given number from 2n-1.
2. For example :-
In hexadecimal number there will
be four bits i.e.,
n=4 => 24-1 = 16-1 = 15.
3. Therefore, to obtain 1’s complement of a given
number we have to subtract that number from 15 i.e., 1111.
For Example :-
Obtain the 1’s complement of
1101 .
Solution:
1st method – The 1’s complement for 1101 is
0010 i.e. in 1’s complement if the given bit is 1 then we have to write 0 and
if the given bit is 0 we have to write 1.
2nd method – We can also obtain one’s
complement by subtracting the given number from 15.
For Example :-
Here the given
number is 13 =>15-13=2.
=>2’s complement
:-
1. We can
obtain the 2’s complement of a given number by subtracting that number from 2n.
2. For example:-
In hexadecimal there will be 4 bits
i.e.
n=4 => 24 = 16.
3. We can also obtain the 2’s complement by adding 1 to 1’s complement.
For Example:-
Obtain 2’s complement for 1001
Solution:
First Method: 24=
16-9=7
Second Method:
1001
1s complement 0110
+ 1
---------
0111 →7.
--------
=>9’s complement
:-
1. To obtain 9’s complement
we have to subtract each digit from 9.
2. For Example:- 8 - 2 = 6
[or]
8
+ 7 ( since 9-2=7)
--------------
1 5
+1 (carry 1)
--------------
6
--------------
=>10’s complement :-
1. We can obtain 10’s complement by adding I to 9’s complement.
NEXT TOPIC: BINARY CODES