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)); }
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); } }
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); }
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); }
public SLongIntD(SLongIntD From) : base((LongIntDecimal)From) { sign = From.sign; }
// 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); }
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); } }
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); }
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)); }
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); }