Example #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));
        }
Example #2
0
 public static big operator ++(big bigInt)
 => BigIntMath.Add(bigInt, big.One);