public override TANumber Div(TANumber a) { if ((a as TNumber).IsZero()) { throw new DivideByZeroException(); } return(new TNumber(Number / (a as TNumber).Number)); }
public override TANumber Sub(TANumber a) { TComplex toReturn = new TComplex(Real - (a as TComplex).Real, Imaginary - (a as TComplex).Imaginary); if (toReturn.Real.ToString().Length > OverflowStringLimit) { throw new OverflowException(); } else if (toReturn.Imaginary.ToString().Length > OverflowStringLimit) { throw new OverflowException(); } return(toReturn); }
public override TANumber Div(TANumber a) { TComplex toReturn = new TComplex((Real * (a as TComplex).Real + Imaginary * (a as TComplex).Imaginary) / ((a as TComplex).Real * (a as TComplex).Real + (a as TComplex).Imaginary + (a as TComplex).Imaginary), ((a as TComplex).Real * Imaginary - Real * (a as TComplex).Imaginary) / ((a as TComplex).Real * (a as TComplex).Real + (a as TComplex).Imaginary * (a as TComplex).Imaginary)); if (toReturn.Real.ToString().Length > OverflowStringLimit) { throw new OverflowException(); } else if (toReturn.Imaginary.ToString().Length > OverflowStringLimit) { throw new OverflowException(); } return(toReturn); }
public override TANumber Sub(TANumber a) { return(new TFrac((a as TFrac).Numerator * Denominator - (a as TFrac).Denominator * Numerator, (a as TFrac).Denominator * Denominator)); }
public override TANumber Add(TANumber a) { return(new TFrac(Numerator * (a as TFrac).Denominator + Denominator * (a as TFrac).Numerator, Denominator * (a as TFrac).Denominator)); }
public override TANumber Sub(TANumber a) { return(new TPNumber((a as TPNumber).Number - Number, Notation, Precision)); }
public abstract TANumber Div(TANumber a);
public abstract TANumber Mul(TANumber a);
public abstract TANumber Add(TANumber a);
public override TANumber Mul(TANumber a) { return(new TNumber(Number * (a as TNumber).Number)); }
public override TANumber Sub(TANumber a) { return(new TNumber(Number - (a as TNumber).Number)); }
public override TANumber Add(TANumber a) { return(new TNumber(Number + (a as TNumber).Number)); }
public abstract TANumber Sub(TANumber a);