# COMPLEMENTS

Complements are used in digital computer to simplify subtraction operation.
There are two types of complements

1. r’s complement

2. ( r-1 )’s complement

consider the binary system with base r = 2. So the complements are 2’s complement and 1’s complement.
Similarly for an octal system we have 8’s complement and 7’s complement.
For decimal system we have r = 10 so we have 10’s complement and 9’s complement.

R’s complement- Example1:– Find the 10’s complement of the given decimal numberer

1. (7634)10

2. (76.34)10

3. (0.456)10

Solve 1. First method

Number of integer digits = n = 4

base = r = 10

number = N = 7634

r n – N = 104 – 7634 = 2366 Answer

Second Method Solve2:- first method

n = 2 r = 10

r n – N = 102 – 76.34 = 23.66 Answer Solve 3:- (.456)10 Example2 :- Find the 2’s complement for the given binary number

1. 1 1 0 1 1

2. 1 1 0 1 . 0 1

Solve1. Here r = 2 n = 5

formula used rn – N = 25– 1 1 0 1 1

= ( 32 )10 – 1 1 0 1 1

= 1 0 0 0 0 0 – 1 1 0 1 1

= 0 0 1 0 1 Answer

Solve 2:- r = 2 n = 4

Formula used            rn – N =24 – 1 1 0 1 . 0 1

= 16 – 1 1 0 1 . 0 1

= 1 0 0 0 0 – 1 1 0 1 . 0 1

= 0 0 1 0 . 1 1 Answer

( r – 1)’s Complement :- Example1:- Find 9’s complement for the given decimal number.

1. 7 5 4 3

2. 6 3 2 . 4 5 6

Solve1>. R = 10 n = 4

( rn – 1 ) – N = 104 – 1 – 7 5 4 3

= 9 9 9 9 – 7 5 4 3

= 2 4 5 6 Answer Solve 2 :-              r = 10 n = 3

( rn – 1 ) – N = 103 – 103– 6 3 2 . 4 5 6

= 1 0 0 0 – . 0 0 1 – 6 3 2 . 4 5 6

= 3 6 7 . 5 4 3 answer

Example2:- fiend the 1’s complement for the given binary number.

1. 1 0 1 1 0

Solve1.   Here r = 2 n = 5

( rn – 1 ) – N = 25 – 1 – 1 0 1 1 0

= 32 – 1 – 1 0 1 1 0

= 1 0 0 0 0 0 – 1 – 1 0 1 1 0

= 0 1 0 0 1 Answer

Subtraction with r’s complement:

1. Equating the number of digits between the minuend and subtrahend, if they are not equal padding with zero is used to make them equal.

2. Find the r’s complement to subtrahend.

3. Add minuend with r’s complement of subtrahend.

(a) if the Sum produce a carry, discard it.
(b) if the Sum does not produce an end around carry, take the r’s complement to the result of sum and place a negative sign in front of it.

Example:- Subtraction using 10’s complement.

1. 7 6 5 3 2 – 4 2 5 0

2. 4 2 5 0 – 7 6 5 3 2

Solve1. 1Step:- equating the number so

7 6 5 3 2 and 0 4 2 5 0 Example 2:- 4 2 5 0 – 7 6 5 3 2  Subtraction with ( r – 1)’s complement:- the following steps are followed

1>. Equate the number of digits in minuend and subtrahend.
2>. Fiend (r – 1)’s complement to the subtrahend.
3>. Add minuend with ( r – 1)’s complement of subtrahend
(a) If the above addition produce a carry,add this carry to the LSB( Least Significant bit) of the sum.
(b) If the above addition does not produce a carry,take the (r – 1)’s complement to the result of above sum and place negative sign in front.

Exapmle1:- perform the following subtraction using 9’s complement.

(a) 7 6 5 3 2 – 4 2 5 0

(b) 5 2 4 0 – 7 6 5 3 2 Solve (b):– Step1. Equate the number of digits so 0 5 2 4 0

Step2. Fiend (r – 1)’s complement to the subtrahend. Comparison between 1’s complement and 2’s complement:- 