mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-04 08:04:37 +08:00
A quotient-only BigInt division with a one-limb quotient returns Knuth's estimate without a pass over the operands when the top limbs prove it: with rhat * B + u0 - qhat * d0 at least qhat, a - qhat * b stays positive whatever the lower limbs hold, since they subtract less than qhat * B^(n-2). Otherwise one pass settles the estimate as before. The add and subtract loops process eight limbs a pass, which rebuilds the carry half as often. Left and right shifts, including the operand normalization of the general division, form each limb from two source limbs in a restrict-qualified helper with no dependency between limbs, so the loops vectorize.