| QUOTE |
- Subtract 10 and add one to the quotient: Sum = 42 q = 1 - Subtract 10 more Sum = 32 q = 2 - Subtract 10 more Sum = 22 q = 3 - Subtract 10 more Sum = 12 q = 4 - Subtract 10 more Sum = 2 q = 5 |
| QUOTE |
| 1) We keep doubling the divisor (10) until the next shift would exceed the dividend (60000) 10>20>40>80>160>320>640>1280>2560>5120>10240>20480>40960. This is 13 shifts so the current multiplier is 4096 which is 2 to the 13 power. Also note that the next shift, to 81920 would exceed the original dividend. 2) We now subtract the expanded divisor from the dividend and add the multipler to the quotient. So afterwords the new dividend will be 19040 and the new quotient is 4096. 3) We then repeat. But instead of starting the 10 over and shifting it up, we simply take the current shifted divisor (40960) and shift it down until it becomes less than the current dividend. So we'd shift down twice 40960->20480->10240 and then update by subtracting the 10240 from the 19040 and add the 1024 (the current multipler) to the quotient. So the dividend becomes 8800 and the quotient becomes 5120 (4096+1024) 4) Repeat until the multipler is 0: |
| CODE |
divisor = 5120 dividend becomes 3680 quotient is 5120+512 -> 5632 divisor = 2560 dividend becomes 1120 quotient is 5632+256 -> 5888 divisor = 1280 dividend remains because the divisor is bigger than the dividend divisor = 640 dividend becomes 480 quotient is 5888+64 -> 5952 divisor = 320 dividend becomes 160 quotient is 5952+32 -> 5984 divisor = 160 dividend becomes 0 quotient is 5984+16 -> 6000 |