Before starting Subtraction Using Complements, let us know what complement is first.
Complements:
Complements are of two types:
1. r’s Complement;
For the given positive number N in base r with an integer part of n-digits, the r’s complement of N is defined as rn-N.
2. (r-1)’s Complement;
For the given positive number N in base r with an integer part of n-digits and fractional parts of the digits, the (r-1)’s complement is defined as rn-r-m-N.
Subtraction Using Complements can be done by two ways:
Subtraction Using r’s Complement:
The subtraction of two positive numbers (M-N) both of base r can be done as follows;
- Add the minuend M to the r’s complement of subtractend N.
- Inspect the result obtained in step 1 for end carry.
- If end carry occurs, discard it.
- If end carry doesn’t occur, take r’s complement if the number obtained in step 1 and place a negative sign in front.
A. For decimal numbers:
Example: Subtract (72532-3250) using 10’s complement.
M= 72532
N= 03250
10’s complement of N= 105-3250 = 96750
Now, adding 10’s complement of N to M,
72532+96750=169282
Here, end carry occurs as 1. So, 10’s complement= 69282
B. For binary numbers:
Example: Subtract (1000100-1010100) using 2’s complement.
M= 1000100
N= 11010100
2’s complement of N=10110
Now, adding 2’s complement of N to M
10110+1000100= 110000
Here, end carry occurs as 1, so 2’s complement = -10000
Subtraction Using r-1’s Complement:
The subtraction of two positive numbers (M-N) both of base r-1 can be done as follows;
- Add the minuend M to the r-1’s complement of subtractend N.
- Inspect the result obtained in step 1 for end carry.
- If end carry occurs, add 1 to the least significant bit, i.e. end-around carry.
- If end carry doesn’t occur, take r-1’s complement of the number obtained in step 1 and place a negative sign in front.
A. For decimal number:
Example: Subtract (453.35-321.17) using 9’s complement.
9’s complement of 321.17= 678.82
Now, Adding 9’s complement of M to N,
453.35+678.82= 1132.17
Here, end carry occur, so 9’s complement = 132.18
B. For binary numbers:
Example: Subtract (1000100-1010100) using 1’s complement.
M= 1000100
N= 11010100
1’s complement of N=101011
Now, adding 1’s complement of N to M
101011+1000100= 1101111
Here, end carry doesn’t occur as 1, so 1’s complement of 1101111= -1000 which is the required answer.
No comments:
Post a Comment