Beispiel #1
0
        private static int CompareBigIntegers(BigInt First, BigInt Second)
        {
            int compare_result;

            if (First.IsNegative() && !Second.IsNegative())
            {
                compare_result = -1;
            }
            else if (!First.IsNegative() && Second.IsNegative())
            {
                compare_result = 1;
            }
            else if (First.IsNegative() && Second.IsNegative())
            {
                return(CompareBigIntegersNeg(First, Second));
            }
            else
            {
                return(CompareBigIntegersPos(First, Second));
            }


            return(compare_result);
        }
        /// <summary>
        ///  Makes full copy of object of BigInt type.
        /// </summary>
        /// <returns>Returns reference on a new object, that has the same values that copied object had.</returns>
        public static BigInt Copy(BigInt number)
        {
            BigInt copied_number = new BigInt();

            if (number.IsNegative())
            {
                copied_number.negative = true;
            }

            for (int i = 0; i < number.numericalRank.Count; i++)
            {
                copied_number.numericalRank.Add(number.numericalRank[i]);
            }

            return(copied_number);
        }