Exemple #1
0
        public void LeftBlockShiftTest()
        {
            Random random = new Random(1234);

            for (int sft = 0; sft < BigUInt <Pow2.N32> .Length; sft++)
            {
                UInt32[] mantissa = UIntUtil.Random(random, BigUInt <Pow2.N32> .Length, BigUInt <Pow2.N32> .Bits - sft * UIntUtil.UInt32Bits);

                BigUInt <Pow2.N32> v  = new BigUInt <Pow2.N32>(mantissa, enable_clone: false);
                BigInteger         bi = v;

                BigUInt <Pow2.N32> v_sft = BigUInt <Pow2.N32> .LeftBlockShift(v, sft);

                BigInteger bi_sft = bi << (sft * UIntUtil.UInt32Bits);

                Console.WriteLine(sft);
                Console.WriteLine(v.ToHexcode());
                Console.WriteLine(v_sft.ToHexcode());
                Assert.AreEqual(bi_sft, v_sft);

                Console.Write("\n");
            }

            Assert.ThrowsException <OverflowException>(() => {
                BigUInt <Pow2.N32> v = new BigUInt <Pow2.N32>(0x12345678u);

                BigUInt <Pow2.N32> v_sft = BigUInt <Pow2.N32> .LeftBlockShift(v, BigUInt <Pow2.N32> .Length);
            });
        }
Exemple #2
0
 public static Accumulator <N> LeftBlockShift(Accumulator <N> n, int sft)
 {
     return(new Accumulator <N>(BigUInt <Double <N> > .LeftBlockShift(n.value, sft)));
 }
Exemple #3
0
 public static Mantissa <N> LeftBlockShift(Mantissa <N> n, int sft)
 {
     return(new Mantissa <N>(BigUInt <N> .LeftBlockShift(n.value, sft)));
 }