Bigint.Mag.fix: def of bend-kit-bignum@0.1.0.0 Import: import bend-kit-bignum@0.1.0.0/bigint.bend as Bigint Lines 206-216 of bend-kit-bignum@0.1.0.0/bigint.bend: https://jend.leeeet.dev/read.txt?path=bend-kit-bignum@0.1.0.0/bigint.bend&start_line=206&end_line=216 import Base # Knuth's Algorithm D step D6: the estimate d is at most 2 over the true # quotient digit, so f = 3 steps of p - bn always settle it. def Mag.fix(+f: Nat, +d: U32, +p: List<&2, U32>, +r: List<&2, U32>, +bn: List<&2, U32>, +q: List<&2, U32>) -> List<&2, U32> & List<&2, U32>: match f: case 0n: (Con{d, q}, Mag.norm(Mag.sub(r, p, 0))) case 1n+g: Mag.if(List<&2, U32> & List<&2, U32>, Cmp.is_gt(Mag.cmp(p, r)), u => Mag.fix(g, (d - 1 : U32), Mag.norm(Mag.sub(p, bn, 0)), r, bn, q), u => (Con{d, q}, Mag.norm(Mag.sub(r, p, 0)))) Uses (11): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Cmp.is_gt https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Pair https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Sigma https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.sub https://jend.leeeet.dev/definition.txt?path=bend-kit-bignum@0.1.0.0/bigint.bend&name=Mag.cmp https://jend.leeeet.dev/definition.txt?path=bend-kit-bignum@0.1.0.0/bigint.bend&name=Mag.if https://jend.leeeet.dev/definition.txt?path=bend-kit-bignum@0.1.0.0/bigint.bend&name=Mag.norm https://jend.leeeet.dev/definition.txt?path=bend-kit-bignum@0.1.0.0/bigint.bend&name=Mag.sub