public static BigInteger operator -(BigInteger a, BigInteger b) { BigInteger nb = new BigInteger(!b.IsPositive, b.Magnitude); return a + nb; }
public static int Compare(BigInteger a, BigInteger b) { if (a.Magnitude == b.Magnitude) { if (a.Magnitude == 0) return 0; if (a.IsPositive == b.IsPositive) return 0; } if (a.IsPositive) { if (b.IsPositive) { return (a.Magnitude > b.Magnitude) ? 1 : -1; } else { return 1; } } else { if (b.IsPositive) { return -1; } else { return (a.Magnitude > b.Magnitude) ? -1 : 1; } } }