コード例 #1
0
 public override TANumber Div(TANumber a)
 {
     if ((a as TNumber).IsZero())
     {
         throw new DivideByZeroException();
     }
     return(new TNumber(Number / (a as TNumber).Number));
 }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
 public override TANumber Sub(TANumber a)
 {
     return(new TFrac((a as TFrac).Numerator * Denominator - (a as TFrac).Denominator * Numerator, (a as TFrac).Denominator * Denominator));
 }
コード例 #5
0
 public override TANumber Add(TANumber a)
 {
     return(new TFrac(Numerator * (a as TFrac).Denominator + Denominator * (a as TFrac).Numerator, Denominator * (a as TFrac).Denominator));
 }
コード例 #6
0
 public override TANumber Sub(TANumber a)
 {
     return(new TPNumber((a as TPNumber).Number - Number, Notation, Precision));
 }
コード例 #7
0
 public abstract TANumber Div(TANumber a);
コード例 #8
0
 public abstract TANumber Mul(TANumber a);
コード例 #9
0
 public abstract TANumber Add(TANumber a);
コード例 #10
0
 public override TANumber Mul(TANumber a)
 {
     return(new TNumber(Number * (a as TNumber).Number));
 }
コード例 #11
0
 public override TANumber Sub(TANumber a)
 {
     return(new TNumber(Number - (a as TNumber).Number));
 }
コード例 #12
0
 public override TANumber Add(TANumber a)
 {
     return(new TNumber(Number + (a as TNumber).Number));
 }
コード例 #13
0
 public abstract TANumber Sub(TANumber a);