To subtract one number from another, you can do the usual arithmetic algorithm, but you can also use an addition process instead that can be handy for checking subtraction results when working by hand. This avoids doing the identical process with which you got your first result lest you inadvertently repeat making an error you might have made the first time.
Consider the following examples:
8718 - 4732 = 3986 This is completely standard arithmetic.
Now, replace the "4732" with its nines complement which in this case means "5267". Each digit of this new number is that which if added to the corresponding digit of the old number, totals to nine. Ergo, 4+5=9, 7+2=9, 3+6=9 and 2+7=9.
Then add: 8718 + 5267 = 13985.
Remove the leading "1" to get "3985" and then add one to this new number. The result is "3986" which is the correct result.
Other examples, same process:
609 - 211 = 398 609 + 788 = 1397 --> 397 + 1 = 398 Correct.
87658 - 419 = 87239 87658 + 99580 = 187238 --> 87238 + 1 = 87239 Correct.
Note in this last example that "419" is taken as "00419" which has two leading zeros whose nines complement is two nines.
Computer people, software people and the inventor of the Curta Mechanical Calculator(*) have had this down pat since forever, but it is useful to have at the ready.
(*) Please see:
http://www.eetimes.com/electronics-blogs/other/4213942/Amazing--The-Curta-Mechanical-Calculator
Interesting but...
What if the result is negative?
23-47 = -24 (standard arithmetic)
23+52 = 75 (9s complement addition)
The method falls apart here BUT if we take the result of the 9s complement addition and do a 9s complement again, we get 24.
Posted by: Bill St.John | June 19, 2011 at 09:38 AM
Hi, Bill.
I don't know how to deal with neagtive results either, it's always been a larger number take away a smaller number for me.
However, this process works in any base including binary for which ones-complment arithmetic is used.
For example: 1011 - 101 = 110 in plain subtrection.
Then: 1011 + 1010 = 10101 --> 0101 + 1 = 110 Correct.
Posted by: John Dunn | June 19, 2011 at 10:16 AM
The method is (assuming x and y contain 4 digits):
x - y = x + (10000 - y) = 10000 + (x - y)
Therefore dropping the leading 1 gives you the correct result.
If (x - y) is negative, you just have to take the 9's complement again:
(e.g. 9's complement of 75 is 24)
Posted by: Bing | June 19, 2011 at 04:35 PM
My previous comment should read:
The method to calculate (x - y) is:
x + (10000 -y) = 10000 + (x - y)
(assuming x and y contain 4 digits)
Note that (10000 - y) us the 10's complement of y, or 9's complement + 1. Dropping the leading 1 gives you the correct result.
If (x - y) is negative, you just have to take the 9's complement again:
10000 - (10000 + (x - y)) = -(x - y)
Just be aware that the result is a negative value
(e.g. 9's complement of 75 is 24, and the actual result is -24)
Hope this clear things up.
Posted by: Bing | June 19, 2011 at 11:09 PM