def fm_go

bend-collections-laws-crypto@1.0.0.0 · src/math/f64.bend:1061

import bend-collections-laws-crypto@1.0.0.0/src/math/f64.bend as F64
import Base
import bend-collections-laws-crypto@1.0.0.0/src/math/u64.bend as W
import bend-collections-laws-crypto@1.0.0.0/src/math/w64.bend as X

1061# (q, r) of mx * 2^d by b from (q0, r0) of mx by b: ten bits a step, so each
1062# partial remainder r * 2^t stays below 2^63
1063def fm_go(fuel: Nat, +b: W.U64, +d: Nat, st: W.U64 & W.U64) -> W.U64 & W.U64:
1064  match fuel d:
1065    case 0n _:
1066      st
1067    case 1n+f 0n:
1068      st
1069    case 1n+f 1n+e:
1070      fm_go(f, b, Nat.sub(1n+e, Nat.min(1n+e, 10n)), X.divmod(X.shl(X.psnd(st), Nat.min(1n+e, 10n)), b))

Uses (8)

Used by (1)