Esempio n. 1
0
        public static big operator -(big lhs, big rhs)
        {
            var isLeftPositive  = lhs.Sign == Sign.Positive;
            var isRightPositive = rhs.Sign == Sign.Positive;

            // +5 - +3 = +(+5 - +3)
            if (isLeftPositive && isRightPositive)
            {
                return(BigIntMath.Subtract(lhs, rhs));
            }

            // -5 - -3 = -5 + 3 = +(-5 + +3)
            if (!isLeftPositive && !isRightPositive)
            {
                return(BigIntMath.Add(lhs, -rhs));
            }

            // 5 - -3 = 5 + 3 = +(+5 + +3)
            if (isLeftPositive)
            {
                return(BigIntMath.Add(lhs, -rhs));
            }

            // -5 - +3 = -5 - 3 = -(5 + 3) = -(+5 + +3)
            return(-BigIntMath.Add(-lhs, rhs));
        }
Esempio n. 2
0
 public static big operator *(big lhs, big rhs)
 => BigIntMath.Multiple(lhs, rhs);
Esempio n. 3
0
 public static big operator ++(big bigInt)
 => BigIntMath.Add(bigInt, big.One);
Esempio n. 4
0
 public static big operator --(big bigInt)
 => BigIntMath.Subtract(bigInt, big.One);