Function addMulLimbWithCarry [src]

a + b * c + *carry, sets carry to the overflow bits

Prototype

pub fn addMulLimbWithCarry(a: Limb, b: Limb, c: Limb, carry: *Limb) Limb

Parameters

a: Limbb: Limbc: Limbcarry: *Limb

Source

pub fn addMulLimbWithCarry(a: Limb, b: Limb, c: Limb, carry: *Limb) Limb { @setRuntimeSafety(debug_safety); // ov1[0] = a + *carry const ov1 = @addWithOverflow(a, carry.*); // r2 = b * c const bc = @as(DoubleLimb, math.mulWide(Limb, b, c)); const r2 = @as(Limb, @truncate(bc)); const c2 = @as(Limb, @truncate(bc >> limb_bits)); // ov2[0] = ov1[0] + r2 const ov2 = @addWithOverflow(ov1[0], r2); // This never overflows, c1, c3 are either 0 or 1 and if both are 1 then // c2 is at least <= maxInt(Limb) - 2. carry.* = ov1[1] + c2 + ov2[1]; return ov2[0]; }