> The ten's complement of 4583 is 5417
It looks like here you are calculating 9999 - 4583 = 5416 (an easy subtraction), then adding one.
> (the complement is the remainder to the next power of ten, in that case to 10000)
Is remainder a correct term here? It's confusing because if you divide 4583/10000, the remainder is 4583. Modulo of -4583 by 10000 is 5417 though.
> This is much easier to calculate than the direct subtraction.
This is not clear to me. Is it because when you calculate 9999-yyyy, you never need to borrow? Or when you calculate 10000-yyyy, you always make a simple borrow? In any case, I feel this still takes some practise because what was a single subtraction becomes two or more steps.
Direct subtraction with paper and pencil isn't much more difficult than direct addition anyway. If you want to do it in your head, I'd prefer a single-step method instead of having to remember the intermediate results.
Or think of a clock. Subtracting X hours is always the same as adding (12-X) hours. Or any circle, turning counterclockwise X degrees is always the same as turning clockwise (360-X) degrees. The trick is being able to take the compliment digit-wise in order to replace a subtraction with an addition. In binary this is just flipping 0 to 1 and vice versa. In base 10 you just need to remember 5 pairs of digits to switch out with each other.
8467 - 4583 =
8467
+ 5416 (9's complement of 4583)
= 13883
+ 1 (10's complement)
= 13884
- 10000
= 3884
>> Direct subtraction with paper and pencil isn't much more difficult than direct addition anyway. If you want to do it in your head, I'd prefer a single-step method instead of having to remember the intermediate results.
This isn't really a technique for humans, but computers. You can implement add with carry pretty easily with a bunch of logic gates, but what about subtraction where you need to jump across several columns to borrow, keeping track across the entire minuend? Computers don't typically have those little tick marks beside each digit, or scrap paper. It is easy to set a "subtracting" flag though, and invert the subtrahend (1's compliment), and then feed the first carry-in of the ALU with the same signal as the subtract flag (add 1 for 2's complement). You could come up with your own complete subtraction logic, but it's definitely easier to use the same core addition with a tiny bit of extra to handle subtraction and then use a method like this.
7 - 3 = 4:
8 4 6 7
- 4 5 8 3
-------------
4
6 is less than 8, so borrow from the next digit. 16 - 8 = 8: 8 3 16 7
- 4 5 8 3
-------------
8 4
3 is less than 5 so borrow from the next digit. 13 - 5 = 8: 7 13 16 7
- 4 5 8 3
-------------
8 8 4
7 - 4 = 3: 7 13 16 7
- 4 5 8 3
-------------
3 8 8 4
And there's the answer!The term 'borrowing' never made sense to me.
Singapore Math uses the term 'regrouping' which makes a lot more sense: https://www.youtube.com/watch?v=mrDIf3YmNFc
When you add, 15+6, you add 5+6 to get 11, and then you regroup the 11 ones into 1 ten and 1 one.
When you subtract 21-6, you regroup the 2 tens into 1 ten and 10 ones. With the original 1 one, you now have 11 ones. Then you subtract the 6 from the 11 ones to get 5 as the last digit.
It’s the same in base 10, if by inverting a digit x you mean replacing it by 9-x.
https://upload.wikimedia.org/wikipedia/commons/5/5d/EarlyCom...
(This is where the "accumulator" terminology for a 1-register machine came from too.)
Let's say you need to calculate
The ten's complement of 4583 is 5417 (the complement is the remainder to the next power of ten, in that case to 10000). A cool property of the ten's complement in the decimal system is that the subtraction above can be rewritten as Which results in This is much easier to calculate than the direct subtraction. It exploits the fact that calculating -x is equal to +(10000 - x) - 10000.The same works for binary and the two's complement, where it is even easier, because calculating the two's complement is equal to inverting all digits and adding 1. It works for any number system by using the complement of the system's base.