Пример #1
0
        public static FixedWidthInteger operator ^(FixedWidthInteger fwi, int power)
        {
            var answer = new FixedWidthInteger();

            answer.digits = fwi.digits;

            for (int i = 1; i < power; i++)
            {
                answer *= fwi;
            }

            return(answer);
        }
Пример #2
0
        /// <summary>
        /// Adds two fixed width integers together. The result is the addition of both integers, and the size
        /// is equal to the size of the smaller of the two integers.
        /// </summary>
        /// <param name="first">The first integer to add</param>
        /// <param name="second">The second integer to add</param>
        /// <returns>The sum of the two integers, with the size of the smaller of the two</returns>
        public static FixedWidthInteger operator +(FixedWidthInteger first, FixedWidthInteger second)
        {
            var result = new FixedWidthInteger();

            if (first.digits.Length < second.digits.Length)
            {
                result.digits = first.digits;
                result.AddDigits(second.digits);
            }
            else
            {
                result.digits = second.digits;
                result.AddDigits(first.digits);
            }

            return(result);
        }