10의 보수 계산
For this explanation, I need to refer to the two numbers being subtracted. Their proper names are the minuend and the subtrahend. The subtrahend is subtracted from the minuend, and the result is the difference:
Minuend
- Subtrahend
------------------------
Difference
To subtract without borrowing, you first subtract the subtrahend not from the minuend but from 999:
You use 999 here because the numbers have 3 digits. If the numbers had 4 digits, you would use 9999. Subtracting a number from a string of 9s results in a number called the nines' complement. The nines' complement of 176 is 823. And it works in reverse: The nines' complement of 823 is 176. What's nice is this: No matter what the subtrahend is, calculating the nines' complement never requires a borrow.
After you've calculated the nines' complement of the subtrahend, you add it to the original minuend:
And finally you add 1 and subtract 1000:
You're finished. The result is the same as before, and never once did you borrow. Why does this work? The original subtraction problem is
253 – 176
If any number is both added to and subtracted from this expression, the result will be the same. So let's add 1000 and subtract 1000:
253 – 176 + 1000 – 1000
This expression is equivalent to
253 – 176 + 999 + 1 – 1000
Now the various numbers can be regrouped, this way:
253 + (999 – 176) + 1 – 1000
And this is identical to the calculation I demonstrated using the nines' complement. We replaced the one subtraction with two subtractions and two additions, but in the process we got rid of all the nasty borrows.
[code]