def Big.divsmall

bend-kit-fmt@0.1.0.0 · fmt.bend:182

import bend-kit-fmt@0.1.0.0/fmt.bend as Fmt
import Base

182# (q + t / s, t % s) for t < 10 s, by repeated subtraction.
183def Big.divsmall(f: Nat, ge: Bool, +q: U32, +t: List<&2, U32>,
184  +s: List<&2, U32>) -> U32 & List<&2, U32>:
185  match f:
186    case 0n:
187      (q, t)
188    case 1n+g:
189      match ge:
190        case False{}:
191          (q, t)
192        case True{}:
193          +t2 = {Big.sub(t, s, 0) : List<&2, U32>}
194          Big.divsmall(g, Cmp.is_ge(Big.cmp(t2, s)), U32.add(q, 1), t2, s)

Uses (10)

Used by (1)