예제 #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);