예제 #1
0
 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);
         }
     }
 }
예제 #2
0
        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);
        }
예제 #3
0
파일: UMul.x.cs 프로젝트: 0xCM/arrows
 public static ref UInt128 UMul128(this ulong lhs, ulong rhs, out UInt128 dst)
 {
     UMul.mul(lhs, rhs, out dst);
     return(ref dst);
 }
예제 #4
0
파일: UMul.x.cs 프로젝트: 0xCM/arrows
 public static ulong Mul64(this uint lhs, uint rhs)
 {
     return(UMul.mul(lhs, rhs));
 }