public static IntervalElement /*!*/ Factory(BigNum inf, BigNum sup) { Contract.Ensures(Contract.Result <IntervalElement>() != null); ExtendedInt /*!*/ i = ExtendedInt.Factory(inf); ExtendedInt /*!*/ s = ExtendedInt.Factory(sup); return(Factory(i, s)); }
// Subtraction public static ExtendedInt /*!*/ operator -(ExtendedInt /*!*/ a, ExtendedInt /*!*/ b) { Contract.Requires(b != null); Contract.Requires(a != null); Contract.Ensures(Contract.Result <ExtendedInt>() != null); if (a is InfinitaryInt) { return(a); } else if (b is InfinitaryInt) { return(UnaryMinus(b)); } else { return(ExtendedInt.Factory(a.Value - b.Value)); } }
// Modulo public static ExtendedInt /*!*/ operator %(ExtendedInt /*!*/ a, ExtendedInt /*!*/ b) { Contract.Requires(b != null); Contract.Requires(a != null); Contract.Ensures(Contract.Result <ExtendedInt>() != null); if (b.IsZero) { return(a.IsPositive ? (ExtendedInt)cachedPlusInf : cachedMinusInf); } if (a is InfinitaryInt) { return(a); } else if (b is InfinitaryInt) { return(b); } else { return(ExtendedInt.Factory(a.Value % b.Value)); } }
// Construct the interval [inf, sup] protected IntervalElement(BigNum infInt, BigNum supInt) { this.inf = ExtendedInt.Factory(infInt); this.sup = ExtendedInt.Factory(supInt); // base(); // to please the compiler... }
// Construct the inteval [val, val] protected IntervalElement(BigNum val) { this.inf = this.sup = ExtendedInt.Factory(val); // base(); }