A decades-old bug in Knuth's long division
In the article, the author recounts their experience while implementing Algorithm D, long division from Donald Knuth's "The Art of Computer Programming". While working on the algorithm, the author found a bug that had gone unnoticed for decades in implementations of the algorithm in cryptographic libraries. The author had been avoiding division at all costs while building a library for arithmetic over prime fields, as division is more complex and computationally expensive than multiplication.
The author then decided to implement long division and used Knuth's Algorithm 4.3.1D as a reference. While implementing the algorithm, the author encountered a bug that caused the algorithm to produce incorrect results for certain inputs. This bug was eventually discovered and a theorem on the correctness of the algorithm was created in the author's honor.
Rewritten by urgent.news; may contain errors — check the original.
Source: kolja.rs