← LibraryMultiprecision Division and RemainderEngineering · MathematicsLesson 211/385← PrevNext →
ArticlePublished 7 Aug 20262 min readBy Kevin Jogindivisionremainderquotient estimationnormalisation

Multiprecision Arithmetic

Multiprecision Division and Remainder

Knuth's division algorithm, the normalisation step that makes quotient digit estimation reliable, and why division carries a larger constant than multiplication.

Engineering / MathematicsMultiprecision Arithmetic2 min readKV-MATH-0509

Division is the most intricate of the basic multiprecision operations. The difficulty is not the outer loop but the inner step: estimating each quotient digit accurately enough that correction is cheap.

The structure

Long division proceeds one quotient limb at a time, from the most significant end. At each step the algorithm estimates the next quotient digit, multiplies it back, subtracts, and corrects if the estimate was too large.

Classical division with remainder

  1. NormaliseShift both operands left so the divisor's leading limb has its top bit set. This is what makes the estimate accurate.
  2. EstimateDivide the leading two limbs of the current remainder by the leading limb of the divisor.
  3. Multiply and subtractMultiply the whole divisor by the estimate and subtract from the remainder.
  4. CorrectIf the subtraction went negative, decrement the estimate and add the divisor back.
  5. DenormaliseShift the remainder right by the normalisation amount. The quotient is unaffected.

Why normalisation matters

Signs and conventions

Division of signed integers admits more than one convention, and they disagree on negative operands. Which one is in force must be known.

Division conventions — they differ only for negative inputs
ConventionRemainder signTypical use
TruncatedFollows the dividendMost programming languages
FlooredFollows the divisorMathematical convention
EuclideanAlways non-negativeNumber-theoretic work

Cost

Classical division is O(k * l) in the limb counts, with a constant noticeably larger than multiplication because of the estimate-and-correct inner loop. Fast division via Newton iteration achieves O(M(n)) but only pays off for large operands.

Source. Henri Cohen, A Course in Computational Algebraic Number Theory, Springer GTM 138 — 1.2.4. Structural reference unverified: the source file was not available during authoring; chapter and section numbers are taken from the published edition and have not been checked against a physical copy.

Continue learning

Asymptotic Cost of Integer MultiplicationArticle · MathematicsNEXT LESSON →Modular Arithmetic and Montgomery ReductionArticle · MathematicsSchoolbook and Karatsuba MultiplicationArticle · MathematicsBinary Powering and Exponentiation ChainsArticle · Mathematics