void VerifyUMul128Powers() { for (var i = 0; i <= 63; i++) { for (var j = 0; j <= 63; j++) { var product = UMul.mul(1ul << i, 1ul << j, out UInt128 _); var bsExpect = BitString.FromPow2(i + j); var bsActual = product.ToBitString(); Trace($"{product.Format()}"); Claim.eq(bsExpect, bsActual); } } }
public void umul64() { void VerifyUMul64(int samples) { var x = Random.Span <uint>(samples); var y = Random.Span <uint>(samples); for (var i = 0; i < samples; i++) { var xi = x[i]; var yi = y[i]; var z = (ulong)xi * (ulong)yi; Claim.eq(z, UMul.mul(xi, yi)); } } VerifyUMul64(Pow2.T12); }
public static ref UInt128 UMul128(this ulong lhs, ulong rhs, out UInt128 dst) { UMul.mul(lhs, rhs, out dst); return(ref dst); }
public static ulong Mul64(this uint lhs, uint rhs) { return(UMul.mul(lhs, rhs)); }