public static IntegerNumber operator -(IntegerNumber a, IntegerNumber b) { if (!Functional.BothAreEqual(a, b, HierarchyLevel.INTEGER)) { return(Number.OpSub(a, b) as IntegerNumber); } return(new IntegerNumber(CtxSubtract(a.Value, b.Value))); }
public static RationalNumber operator -(RationalNumber a, RationalNumber b) { if (!Functional.BothAreEqual(a, b, HierarchyLevel.RATIONAL)) { return(Number.OpSub(a, b) as RationalNumber); } var num = CtxSubtract(CtxMultiply(a.Numerator, b.Denominator), CtxMultiply(b.Numerator, a.Denominator)); var den = CtxMultiply(a.Denominator, b.Denominator); return(Number.Functional.Downcast(new RationalNumber(num, den)) as RationalNumber); }
public static ComplexNumber operator -(ComplexNumber a, ComplexNumber b) { if (!Functional.BothAreEqual(a, b, HierarchyLevel.COMPLEX)) { return(Number.OpSub(a, b) as ComplexNumber); } var Re = a.Real - b.Real; var Im = a.Imaginary - b.Imaginary; return(Number.Functional.Downcast(new ComplexNumber(Re, Im)) as ComplexNumber); }
public static RealNumber operator -(RealNumber a, RealNumber b) { if (!a.IsDefinite() || !b.IsDefinite()) { return(UndefinedStateSuperSwitch.Switch( () => new RealNumber(UndefinedState.NAN), () => new RealNumber(UndefinedState.NAN), () => new RealNumber(UndefinedState.NEGATIVE_INFINITY), () => new RealNumber(UndefinedState.POSITIVE_INFINITY), () => new RealNumber(UndefinedState.POSITIVE_INFINITY), () => new RealNumber(UndefinedState.NEGATIVE_INFINITY), () => new RealNumber(UndefinedState.NEGATIVE_INFINITY), () => new RealNumber(UndefinedState.POSITIVE_INFINITY), a, b)); } if (!Functional.BothAreEqual(a, b, HierarchyLevel.REAL)) { return(Number.OpSub(a, b) as RealNumber); } return(Number.Functional.Downcast(new RealNumber(CtxSubtract(a.Value, b.Value))) as RealNumber); }