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)); }
Equals( Polynomial polynomial1, Polynomial polynomial2 ) { if (polynomial1 == null) { return(polynomial2 == null); } return(polynomial1.Equals(polynomial2)); }
/// <summary> /// Check whether two polynomials are equal. /// </summary> public static bool Equals( Polynomial polynomial1, Polynomial polynomial2 ) { if(polynomial1 == null) { return polynomial2 == null; } return polynomial1.Equals(polynomial2); }