def Mag.dsmall
import bend-kit-bignum@0.1.0.0/bigint.bend as Bigintimport Base
192# Short division of a big-endian list by d below 10^4 with remainder rem:
193# the quotient comes out little-endian, with zero limbs on top.
194def Mag.dsmall(xs: List<&2, U32>, +d: U32, +rem: U32, acc: List<&2, U32>) ->
195 List<&2, U32>:
196 match xs:
197 case Nil{}:
198 acc
199 case Con{x, t}:
200 +v = (rem * 10000 + x : U32)
201 Mag.dsmall(t, d, (v % d : U32), Con{(v / d : U32), acc})