Add( Rational rational ) { if (denominator.Equals(rational.denominator)) { return(new Rational( numerator + rational.numerator, denominator.Clone() )); } Polynomial num = numerator * rational.denominator + rational.numerator * denominator; Polynomial denom = denominator * rational.denominator; return(new Rational(num, denom)); }
Rational( Polynomial numerator, Polynomial denominator ) { this.numerator = numerator.Clone(); this.denominator = denominator.Clone(); }
Divide( Polynomial polynomial ) { return(new Rational( numerator.Clone(), denominator * polynomial )); }
Divide( Polynomial polynomial ) { return(new Rational(Clone(), polynomial.Clone())); }
/// <summary> /// Divides this polynomial with anoter polynomial. /// </summary> public Rational Divide( Polynomial polynomial ) { return new Rational(Clone(), polynomial.Clone()); }