fixed 1.3.1 — the 256-bit division goes by limbs
A pure speed change to fixUInt256DivMod, and the frozen hashes prove it: every one in the repository is unchanged, so the new divider agrees bit for bit with the old one everywhere this library divides.
What was slow. The 256-bit division was shift-subtract — one iteration per bit of the dividend, around two hundred, each a 256-bit shift, compare and subtract. Exact, and fine while nothing hot reached it. Something hot now does: a consumer storing inverse quantities at Q24.40 puts a 3x3 solve of 2^40-scaled values in a per-substep path, and cofactors of those values exceed the 128-bit arm's limit by construction, so every one of those solves lands here. It measured +503% on a joint-heavy scene.
What it is now. Knuth Algorithm D over 64-bit limbs: at most three 128-by-64 divides instead of two hundred bit steps. fixUInt128DivRemBy64 is the new seam primitive that makes it possible — the divq instruction on x86_64, shift-subtract on Windows targets that lack it (ClangCL does not link compiler-rt builtins), the compiler's divide elsewhere, and the existing emulated divide on the emulated arm. Plain MSVC needs nothing new.
The test found the thing the test was for. It was written first, with the old implementation kept inside it as the oracle — known-correct, already shipped, and sharing no code with the algorithm that replaced it, since one walks bits and the other walks limbs.
Then its coverage was measured rather than assumed, and the first version reached the add-back branch exactly zero times. Its hand-written "add-back vectors" looked plausible and tested nothing: that branch fires for roughly one input in 2^63 and cannot be reasoned onto by eye. Eight real vectors were found by instrumenting and searching, the generator that produced them is in the test too, and the negative control now removes the add-back specifically — so a sweep that stops covering it turns the control green, and a green control is a failure.
Coverage across the suite: 5,370 estimate corrections, 4,008 add-backs, 4,542 zero-shift normalizations, 1,214 maximum-shift normalizations, 37 equal-top-limb entries.
Clean under UBSan on both 128-bit arms, and the new suite runs on the emulated arm too — which is the only coverage the emulated 128-by-64 divide has.