Exemple #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));
        }
Exemple #2
0
 public static big operator *(big lhs, big rhs)
 => BigIntMath.Multiple(lhs, rhs);
Exemple #3
0
 public static big operator ++(big bigInt)
 => BigIntMath.Add(bigInt, big.One);
Exemple #4
0
 public static big operator --(big bigInt)
 => BigIntMath.Subtract(bigInt, big.One);