예제 #1
0
파일: Test.cs 프로젝트: Ribtoks/LongInt
        public void TestShifts1()
        {
            SLongIntB A = new SLongIntB("-98276598235872");
            SLongIntB B = new SLongIntB(A);

            for (int i = 0; i < 10; ++i)
            {
                A.Shr();
                B /= 2;
                Assert.AreEqual(A, B);
            }

            for (int i = 0; i < 10; ++i)
            {
                A.Shl();
                B *= 2;
                Assert.AreEqual(A, B);
            }
        }
예제 #2
0
파일: Test.cs 프로젝트: Ribtoks/LongInt
        public void TestShiftRight()
        {
            SLongIntB N = new SLongIntB("2945729752935981200000005151659293467923476293623");
            RandomLong rand = new RandomLong((ulong)DateTime.Now.Millisecond);

            for (int i = 0; i < 1000; ++i)
            {
                SLongIntB temp1 = new SLongIntB(rand.Next(N), ConstructorMode.Assign);
                SLongIntB temp3 = new SLongIntB(temp1);

                temp1.Shr();

                SLongIntB temp2 = new SLongIntB(temp1);
                temp2.Shl();

                Assert.AreEqual(temp1 * 2, temp2);
                Assert.AreEqual(temp1, temp3 / 2);
            }
        }