public static Fraction Mult(Fraction left, Fraction right) { Fraction result = new Fraction(left.numerator, left.denominator); result.numerator *= right.numerator; result.denominator *= right.denominator; result.Reduce(); return result; }
public static Fraction Add(Fraction left, Fraction right) { Fraction result = new Fraction(left.numerator, left.denominator); int lcd = LCD(result.denominator, right.denominator); result.numerator = result.numerator * lcd / result.denominator; result.numerator += right.numerator * lcd / right.denominator; result.denominator = lcd; result.Reduce(); return result; }
public static Fraction Sub(Fraction left, Fraction right) { return Add(left, new Fraction(-right.numerator, right.denominator)); }