Subtraction
of numbers by using complement
Subtraction
with r’s Complements
The
direct method of subtraction taught in elementary schools uses the borrow
concept. In this method, we borrow a 1 from a higher significant position when
the minuend digit is smaller than the corresponding subtrahend digit. This
seems to be easiest when people perform subtraction with paper and pencil. When
subtraction is implemented by means of digital components, this method is found
to be less efficient than the method that uses complements and addition as
stated below.
The subtraction of two positive numbers (M
- N), both of base r, may be done as follows:
1.
Add
the minuend M to r’s complement of the subtrahend N.
2.
Inspect
the result obtained in step 1 for an end carry:
a.
If the
end carry occurs, discard it.
b.
If an
end carry does not occur, take r’s complement of the number obtained in step 1
and place a negative sign in front.
If you don't understand about r's complement Click Complement of a Number
The
following example illustrate the procedure:
Ex1.
Using 10’s complement subtract 72532 – 3250
Sol. M
= 72532, N = 03250
10’s complement of N = 96750
Now add M + 10’s complement of N
72352 + 96750 = 1 69282, where 1
is end carry, discard it as per step 1
Now the answer is 69282
Ex2.
Subtract 3250 – 72352
Sol. M
= 03250
N = 72352
10’s complement of N = 27468
Now add M + 10’s complement of N
03250 + 27468 = 30718, There we don’t
have any carry then we find 10’s complement of result 30718
Which is -69282
Ex3.
Subtract binary numbers 1010100 – 1000100 using 2’s complement
Sol. M
= 1010100, N = 1000100
2’s complement of N = 0111100
Now add M + 2’s complement of N
1010100 + 0111100 = 1 0010000,
where 1 is end carry, discard as per step 1
Now the answer is 0010000 or 10000
Ex4.
Subtract binary numbers 1000100 – 1010100
Sol. M = 1000100, N = 1010100
2’s complement of N = 0101100
Now add M + 2’s complement of N
1000100 + 0101100 = 1110000, here we
don’t have any carry then we find 2’s complement of result 1110000
Which is -10000
Subtraction
with (r -1)’s complement
The
procedure for subtraction with the (r - 1)’s complement is exactly the same as
the one used with the r’s complement except for one variation, called
‘end-around carry,’ as shown below. The subtraction of M-N, both positive
numbers in base r, may be calculated in the following manner:
1.
Add
the minuend M to (r - 1)’s complement of the subtrahend N.
2.
Inspect
the result obtained in step 1 for an end carry.
a.
In an
end carry occurs, add 1 to the least significant digit (end-around carry).
b.
If an
end carry does not occur, take the (r - 1)’s complement of the number obtained
in step 1 and place negative sign in front.
The
following examples illustrate the procedure.
Note
we are using same examples which we have discussed in r’s complement
Ex1. M
= 72532, N = 03250
Sol.
9’s complement of N = 96749
Now add M + 9’s complement of N
72532 + 96749 = 1 69281, where 1
is end around carry, let’s add this 1 in 69281
The answer is 69281 + 1 = 69282
Ex2. M
= 03250, N = 72532
Sol.
9’s complement of N = 27467
Now add M + 9’s complement of N
03250 + 27467 = 30717, here we don’t
have any carry, then we find 9’s complement of 30717
9’s
complement of 30717 is -69282
Ex3. M
= 1010100, N = 1000100
Sol. 1’s
complement of N = 0111011
Now add M + 1’s complement of N
1000100 + 0111011 = 1 0001111,
where 1 is end-around carry, let’s add this 1 in 0001111
The answer is 0001111 + 1 = 0010000
Ex4. M
= 1000100, N = 1010100
Sol. 1’s
complement of N = 0101011
Now add M + 1’s complement of N
1000100 + 0101011 = 1101111, here we don’t
have any carry, then we find 1’s complement of 1101111
Comments
Post a Comment