public static Fraction operator /(Fraction f1, Fraction f2) { if (f1.IsNaN || f2.IsNaN) return NaN; Fraction f = new Fraction( (f2.Numerator < 0 ? -1 : 1) * f1.Numerator * f2.Denominator, (f2.Numerator < 0 ? -1 : 1) * f1.Denominator * f2.Numerator); f.reduce(); return f; }
public bool Equals(Fraction f) { if (IsNaN && f.IsNaN) return true; if (IsNaN || f.IsNaN) return false; if (Numerator == 0 && f.Numerator == 0) return true; this.reduce(); f.reduce(); return Numerator == f.Numerator && Denominator == f.Denominator; }