/// <summary> /// Gibt Absolutwert wieder /// </summary> /// <param name="frac">Bruch</param> /// <returns>Absolutwert</returns> public static Fraction Abs(Fraction frac) { Fraction result = new Fraction(frac); result.CancelDown(); if (result.Numerator < 0) { result.m_Numerator *= -1; } return(result); }
/// <summary> /// Vergleich /// </summary> /// <param name="obj"></param> /// <returns></returns> public override bool Equals(object obj) { if (obj is Fraction) { CancelDown(); Fraction other = new Fraction(obj as Fraction); other.CancelDown(); return(other.Numerator == m_Numerator && other.Denominator == m_Denominator); } if (obj is int) { CancelDown(); int other = (int)obj; return(other == m_Numerator && 1 == m_Denominator); } return(false); }