Esempio n. 1
0
        static void Main(string[] args)
        {
            HugeInteger hG1 = new HugeInteger("");
            HugeInteger hG2 = new HugeInteger("");
            Console.Write("Enter first HugeInteger: ");
            hG1.Input(Console.ReadLine());

            Console.Write("Enter second HugeInteger: ");
            hG2.Input(Console.ReadLine());

            Console.WriteLine("Huge Integer 1: {0}", hG1.ToString());
            Console.WriteLine("Huge Integer 2: {0}", hG2.ToString());

            HugeInteger sum, difference;
            sum = HugeInteger.Add(hG1, hG2);
            Console.WriteLine("Add result: {0}", sum.ToString());
            difference = HugeInteger.Subtract(hG1, hG2);
            Console.WriteLine("Subtract result: {0}", difference.ToString());

            Console.WriteLine("Huge Integer 1 is zero: {0}", hG1.IsZero());
            Console.WriteLine("Huge Integer 2 is zero: {0}", hG2.IsZero());

            Console.WriteLine("HugeInteger 1 is equal to HugeInteger 2: {0}", hG1.IsEqualTo(hG2));
            Console.WriteLine("HugeInteger 1 is not equal to HugeInteger 2: {0}", hG1.IsNotEqual(hG2));
            Console.WriteLine("HugeInteger 1 is greater than HugeInteger 2: {0}", hG1.IsGreaterThan(hG2));
            Console.WriteLine("HugeInteger 1 is less than HugeInteger 2: {0}", hG1.IsLessThan(hG2));
            Console.WriteLine("HugeInteger 1 is greater than or equal to HugeInteger 2: {0}", hG1.IsGreaterThanOrEqualTo(hG2));
            Console.WriteLine("HugeInteger 1 is less than or equal to HugeInteger 2: {0}", hG1.IsLessThanOrEqualTo(hG2));
        }
Esempio n. 2
0
        public void Test1()
        {
            var hint  = new HugeInteger("5");
            var hint2 = new HugeInteger("-5");

            var r = hint.ToString();

            Console.WriteLine(r);

            r = hint2.ToString();
            Console.WriteLine(r);

            var hint3 = hint + hint2;

            r = hint3.ToString();
            Console.WriteLine(r);

            var intv  = 65464643;
            var intv2 = 54645646464;
            var intv3 = intv + intv2;
            var intv4 = intv3 * 17;

            hint  = intv;
            hint2 = intv2;
            hint3 = hint + hint2;
            var hint4 = hint3 * 17;

            Assert.Equal(intv3.ToString(), hint3.ToString());
            Assert.Equal(intv4.ToString(), hint4.ToString());

            hint  = "6546467575467543567546754356786546786545678654356786543";
            hint2 = "2312345654457653432406755434793810849473931759308439374375893392850934937594794890285089275938404644983879387239";
            hint4 = hint + hint2;
            Console.WriteLine(hint4);

            hint4 = hint * hint2;
            Console.WriteLine(hint4);

            hint4 = hint2 - hint2;
            Console.WriteLine(hint4);

            hint  = "14";
            hint2 = "221";
            hint3 = hint / hint2;
            hint4 = hint2 / hint;
            Console.WriteLine(hint3);
            Console.WriteLine(hint4);

            hint3 = hint % hint2;
            hint4 = hint2 % hint;
            Console.WriteLine(hint3);
            Console.WriteLine(hint4);

            hint  = "654";
            hint2 = "11205675467544";
            hint3 = hint / hint2;
            hint4 = hint2 / hint;
            Console.WriteLine(hint3);
            Console.WriteLine(hint4);

            hint  = "10";
            hint3 = hint.Power(2);
            Console.WriteLine(hint3);

            hint  = long.MaxValue;
            hint3 = hint.Power(20);
            Console.WriteLine(hint3);
        }