! Parameters: ! - %RADIX% radix ! - %DIVISOR% full divisor ! - %DIVISOR_APPROX% the approximated divisor ! - %ITERATION_INDEX% index of the current iteration ! - %ITERATION_INDEX_NEXT% index of the next iteration ! - %QUOTIENT_GUESS% the quotient digit guessed in the current iteration ! - %QUOTIENT_DIGITS% all quotient digits guessed so far, including the current iteration's guess, separated by commas ! - %ASS_QUOTIENT_UNSHIFTED% the unshifted assembled quotient for the current iteration ! - %ASS_QUOTIENT% the shifted assembled quotient for the current iteration ! - %INPUT_EXP_DIFF% exp(dividend) - exp(divisor) (of the base 2 representation) ! - %CARRY_PREV% carry at the beginning of the iteration ! - %CARRY_PREV_APPROX% approximated carry at the beginning of the iteration ! - %REMAINDER_PREV% remainder at the beginning of the iteration ! - %REMAINDER_PREV_APPROX% approximated remainder at the beginning of the iteration ! - %REMAINDER_APPROX% approximated remainder, after adding CARRY_PREV_APPROX ! - %QD_SHIFTED_B4_NEG% qd after shift (multiplication) but before negating ! - %NEG_QD% -d_{k} * d ! - %CARRY_UNSHIFTED% carry after the current iteration, unshifted ! - %CARRY_SHIFTED% carry after the current iteration, shifted ! - %REMAINDER_UNSHIFTED% remainder after the current iteration, unshifted ! - %REMAINDER_SHIFTED% remainder after the current iteration, shifted

### Iteration %ITERATION_INDEX%

• Choose quotient digit $$q_{%ITERATION_INDEX%}$$
• Approximate remainder

$$\begin{array}{cll} & %CARRY_PREV_APPROX%_{2} & \quad \text{(carry)} \\ + & %REMAINDER_PREV_APPROX%_{2} & \quad \text{(prev. remainder)} \\ \hline & %REMAINDER_APPROX%_{2} & \quad \text{(approx. remainder)} \\ \end{array}$$

• Look up quotient digit

$$q_{%ITERATION_INDEX%} = \text{lookup_table}(p: %REMAINDER_APPROX%_{2}, d: %DIVISOR_APPROX%_{2}) = %QUOTIENT_GUESS%$$

$$q = [%QUOTIENT_DIGITS%]_{%RADIX%} = %ASS_QUOTIENT_UNSHIFTED%_{10} * 2^{%INPUT_EXP_DIFF%} = %ASS_QUOTIENT%_{10}$$

• Calculate $$c_{%ITERATION_INDEX_NEXT%}, r_{%ITERATION_INDEX_NEXT%} = c_{%ITERATION_INDEX%} + r_{%ITERATION_INDEX%} + (-q_{%ITERATION_INDEX%}d)$$
• Multiply the quotient digit guess w/ the divisor:

$$\begin{array}{rr} -q_{%ITERATION_INDEX%}d = & -(%QUOTIENT_GUESS%_{10} * %DIVISOR%_{2}) \\ = & -(%QD_SHIFTED_B4_NEG%_{2}) \\ = & %NEG_QD%_{2} \end{array}$$

• $$c_{%ITERATION_INDEX_NEXT%}, r_{%ITERATION_INDEX_NEXT%} = c_{%ITERATION_INDEX%} + r_{%ITERATION_INDEX%} + (-q_{%ITERATION_INDEX%}d):$$

$$\begin{array}{cll} & %CARRY_PREV%_{2} & \quad c_{%ITERATION_INDEX%} \\ + & %REMAINDER_PREV%_{2} & \quad r_{%ITERATION_INDEX%} \\ + & %NEG_QD%_{2} & \quad -q_{%ITERATION_INDEX%}d \\ \hline & %CARRY_UNSHIFTED%_{2} & \quad c_{%ITERATION_INDEX_NEXT%} \\ & %REMAINDER_UNSHIFTED%_{2} & \quad r_{%ITERATION_INDEX_NEXT%} \end{array}$$

• $$c_{%ITERATION_INDEX_NEXT%}, r_{%ITERATION_INDEX_NEXT%} \mathrel{*}= %RADIX%:$$

\begin{align*} c_{%ITERATION_INDEX_NEXT%} &= %CARRY_SHIFTED%_{2} \\ r_{%ITERATION_INDEX_NEXT%} &= %REMAINDER_SHIFTED%_{2} \\ \end{align*}