def q_fix
import bend-collections-laws-math@1.0.0.0/src/math/w64.bend as W64import Base
import bend-collections-laws-math@1.0.0.0/src/math/u64.bend as W
305# q - 1 while q * b > x: at most q steps (fuel q + 1)
306def q_fix(fuel: Nat, +xl: W.U64, +xh: U32, +b: W.U64, +q: U32, over: Bool) -> U32:
307 match fuel over:
308 case 0n _:
309 q
310 case 1n+f False{}:
311 q
312 case 1n+f True{}:
313 q_fix(f, xl, xh, b, U32.sub(q, 1), over96(xl, xh, mul_32_64(U32.sub(q, 1), b)))