public static Fraction operator +(Fraction l, Fraction r) { if (l.Numerator == Empty.Numerator || l.Denominator == Empty.Denominator) if (r.Numerator == Empty.Numerator || r.Denominator == Empty.Denominator) { Fraction f = 0; return Empty; } else return r; if (r.Numerator == Empty.Numerator || r.Denominator == Empty.Denominator) return l; uint CommonDenominator = Common.LCM(l.Denominator, r.Denominator); Fraction fr = new Fraction(l.Numerator * CommonDenominator / l.Denominator + r.Numerator * CommonDenominator / r.Denominator, CommonDenominator); return fr.Cancel(); }
public static Fraction operator *(Fraction l, Fraction r) { if (l.Numerator == Empty.Numerator || l.Denominator == Empty.Denominator) if (r.Numerator == Empty.Numerator || r.Denominator == Empty.Denominator) return Empty; else return r; if (r.Numerator == Empty.Numerator || r.Denominator == Empty.Denominator) return l; Fraction fr = new Fraction(l.Numerator * r.Numerator, l.Denominator * r.Denominator); return fr.Cancel(); }