示例#1
0
文件: Test.cs 项目: Ribtoks/LongInt
        public void PowerTest3()
        {
            SLongIntD A = new SLongIntD("-98276598235872");
            short r = 12, s = 31;

            Assert.AreEqual(LongMath.Exp(A, (ulong)(r + s)), LongMath.Exp(A, (ulong)r) * LongMath.Exp(A, (ulong)s));
        }
示例#2
0
文件: Test.cs 项目: Ribtoks/LongInt
        public void TestAddition2()
        {
            SLongIntD A = new SLongIntD("-982");
            SLongIntD B = new SLongIntD(A);

            for (int i = 1; i < 1000; ++i)
            {
                A++;
                Assert.AreEqual(A, B + (short)i);
            }
        }
示例#3
0
文件: Test.cs 项目: Ribtoks/LongInt
        public void TestAddition1()
        {
            SLongIntD A = new SLongIntD("-98276598235872687523562056");
            SLongIntD B = (SLongIntD)0;
            short k = 120;

            for (int i = 0; i < (int)k; ++i)
                B += A;

            Assert.AreEqual(k*A, B);
        }
示例#4
0
文件: Test.cs 项目: Ribtoks/LongInt
        public void PowerTest1()
        {
            SLongIntD A = new SLongIntD("-98276598235872");
            SLongIntD B = (SLongIntD)1;
            short k = 120;

            for (int i = 0; i < (int)k; ++i)
                B *= A;

            Assert.AreEqual(LongMath.Exp(A, (ulong)k), B);
        }
示例#5
0
 public SLongIntD(SLongIntD From)
     : base((LongIntDecimal)From)
 {
     sign = From.sign;
 }
示例#6
0
        // calculates result of division of signed long number on short number
        public static SLongIntD operator /(SLongIntD A, short b)
        {
            if (System.Math.Abs(b) == 1)
            {
                SLongIntD res = new SLongIntD(A);

                if (b < 0)
                    res.ChangeSign();

                return res;
            }

            bool sign = false;
            LongIntBase temp = LongMath.Divide(A, A.IsPositive, b, out sign);

            return new SLongIntD(temp, SignTransformer.GetLSign(sign), ConstructorMode.Assign);
        }
示例#7
0
文件: Test.cs 项目: Ribtoks/LongInt
        public void TestSubstraction2()
        {
            SLongIntD A = new SLongIntD("239");
            SLongIntD B = new SLongIntD(A);

            for (int i = 1; i < 1000; ++i)
            {
                --A;
                Assert.AreEqual(A, B - (short)i);
            }
        }
示例#8
0
文件: Test.cs 项目: Ribtoks/LongInt
        public void TestSubstraction1()
        {
            SLongIntD A = new SLongIntD("-2945729752935981200000005151659293467923476293623");
            SLongIntD B = new SLongIntD("2398762987692620872000000");

            SLongIntD C = A + B;

            Console.WriteLine(C);

            Assert.AreEqual(C - A, B);
            Assert.AreEqual(C - B, A);

            Assert.AreEqual(C - 0, C);

            Assert.AreEqual(C - C, (SLongIntD)0);
        }
示例#9
0
文件: Test.cs 项目: Ribtoks/LongInt
        public void TestDivision2()
        {
            SLongIntD A = new SLongIntD("-2945729752935981200000005151659293467923476293623");
            SLongIntD B = new SLongIntD("2398762987692620872000000");

            Console.WriteLine((A % B).ToString());

            Assert.AreEqual(LongMath.Abs((B * (A / B))) + (A % B), LongMath.Abs(A));
        }
示例#10
0
文件: Test.cs 项目: Ribtoks/LongInt
        public void TestDivision1()
        {
            SLongIntD A = new SLongIntD("-2945729752935981200000005151659293467923476293623");
            SLongIntD B = new SLongIntD("2398762987692620872000000");
            SLongIntD C = A*B;

            Assert.AreEqual(C / B, A);
            Assert.AreEqual(C / A, B);
        }