def Big.sub

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

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

150# a - b for a >= b; w is the borrow.
151def Big.sub(a: List<&2, U32>, b: List<&2, U32>, w: U32) -> List<&2, U32>:
152  match a b:
153    case Con{x, xs} Con{y, ys}:
154      +t = {U32.sub(U32.sub(U32.add(x, 65536), y), w) : U32}
155      Con{U32.and(t, 65535), Big.sub(xs, ys, U32.sub(1, U32.shrn(t, 16n)))}
156    case _ _:
157      Nil{}

Uses (6)

Used by (1)