def Big.mul

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

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

133# m and c stay below 2^16, so a limb product fits a U32.
134def Big.mul(a: List<&2, U32>, +m: U32, c: U32) -> List<&2, U32>:
135  match a:
136    case Nil{}:
137      Nil{}
138    case Con{x, xs}:
139      +t = {U32.add(U32.mul(x, m), c) : U32}
140      Con{U32.and(t, 65535), Big.mul(xs, m, U32.shrn(t, 16n))}

Uses (6)

Used by (6)