0
$\begingroup$

What would be the right approach to perform a generic long division in base b given the ability:

  1. to compute additions, multiplications, and subtractions in base b
  2. given digit $a$ and digit $b$ find digits $q$ and r s.t. $a = q b + r$ with r < $b$

The tricky part is the "guessing" that comes in a long division. Dichotomy is a possibility but seems rather inelegant. Assume $b$ is large enough to make any type of multiplication table lookup impossible.

  • 0
    What do you mean by dichotomy? The "guessing" in long division doesn't need to involve any guessing: you use short division (of a 1 or 2 digit number by a 1 digit number) to get an upper bound on the next digit of the quotient and then work down from that upper bound until you find the correct answer. To do the short division of a 2 digit number by a 1 digit number use a similar approach using the ability (that you are given) to divide two 1 digit numbers. However, there is no such thing as a "right approach" to this question.2017-01-13
  • 0
    How do you divide a 2 digit number by a 1 digit number using the ability to divide two 1 digit numbers ?2017-01-13
  • 0
    Here's what comes to mind: to divide $u B + v$ by $w$, first divide $B-1$ by $w$ : $B = q w + r + 1$, so $u B + v = u q w + u (r + 1) + v$. Subtract $u q w$. If $u ( r + 1 ) + v \ge B$, repeat, otherwise use one digit division. Anything cleverer?2017-01-13
  • 0
    Same idea as the long division: use single digit division to give you an upper bound and then work down. E.g., in base $10$, for $98 \div 2$ your upper bound is $50$ obtained by dividing $9$ by $2$ to get a quotient $q = 4$ and taking $(q+1)\times 10 = 50$ as your upper bound. Now work down.2017-01-13
  • 0
    Our last two comments "crossed in the post". I am not claiming anything clever about my suggestions, which are just intended to clarify that the classical pencil-and-paper algorithm doesn't actually involve any guesswork.2017-01-13
  • 0
    The case where $u > w$ or 9 > 2 in your example is taken care of by the long division algorithm. The problem is when $u < w$, so for instance $(2345 * 10^4 + 1234) / 3456$2017-01-14
  • 0
    I was giving the general algorithm for dividing a 2 digit number by a 1 digit number. It still works in the specific case you need for use in long division. E.g., in base $10$, for $41 \div 5$, you work down from $10 =(q + 1)\times 10$, where $q= 0$ is the quotient when you divide $4$ by $5$. In long division, you can optimise the algorithm by only considering that case. I reiterate that my points are that the classical pencil-and-paper algorithm involves no guesswork and that there is no "right" approach.2017-01-14
  • 0
    I'm still confused. When you do 41 / 5, 4 / 5 gives you 0. Then what?2017-01-14
  • 0
    Then you have $q = 0$ and you work down from$(q+1)\times 10 = 10$.2017-01-14
  • 0
    What do you mean by work down?2017-01-14
  • 0
    You start with $10$ and see if it works. If it doesn't you try $9$ and so on.2017-01-14
  • 0
    What if b=2^64 ?2017-01-14
  • 0
    Then you count down from $2^{64}$. You can use a binary chop technique to do that quite efficiently. If you still want to pursue this question, can you please edit it to identify the points about the classical long division algorithm that you are concerned about;2017-01-14
  • 1
    I specifically mentioned dichotomy as an option and that the base was very large in the description of the problem. You're adding a log(b) factor in the complexity that may not need be there.2017-01-14
  • 0
    Seems like I had an ESL moment. By dichotomy I meant binary search.2017-01-14

0 Answers 0