The story’s score and claims

Comments on No. 22 of 57 · Kolja · edition of Monday 30 November 2026

A decades-old bug in Knuth's long division

Summary

Kolja, an independent developer, reports a flaw in Knuth's Algorithm D (long division, TAOCP vol. 2) found while implementing it for a prime-field library. A 1995 change swapped the saturated x86-style trial quotient for an ARM-style two-limb one without updating Theorem B. The trial quotient can then reach q+3, and the smallest failing case is base 3, 45/16. It needs an odd base, so 2^64 limbs are unaffected. Most implementations loop in step D3, which masks it. The errata dates and the llvm claim are unverified.

Comments

Ranked by a public rubric, not by votes: what a comment adds counts, not who wrote it. How comments are ranked · Comment rules