def Mag.dec
import bend-kit-bignum@0.1.0.0/bigint.bend as Bigintimport Base
78# a - w for the borrow w; z says w is 0. Leaves zero limbs on top.
79def Mag.dec(a: List<&2, U32>, z: Bool, +w: U32) -> List<&2, U32>:
80 match a z:
81 case s True{}:
82 s
83 case Nil{} False{}:
84 Nil{}
85 case Con{x, xs} False{}:
86 +t = (x + 10000 - w : U32)
87 +k = (1 - t / 10000 : U32)
88 Con{(t % 10000 : U32), Mag.dec(xs, U32.is_zero(k), k)}