public void ConvertFromInt() { Rational r = 5; AssertEqual(5, 1, r); }
public void AssertEqual(int expectedNumerator, int expectedDenominator, Rational actual) { Assert.False(actual.IsNan); Assert.AreEqual(expectedNumerator, actual.Numerator); Assert.AreEqual(expectedDenominator, actual.Denominator); }
public void ConvertToDouble(int numerator, int denominator, double expectedValue) { double v = new Rational(numerator, denominator); Assert.AreEqual(expectedValue, v, 1e-7); }
private static Rational MoveSignToNumerator(Rational rational) { return(new Rational(rational.Numerator * Math.Sign(rational.Denominator), rational.Denominator * Math.Sign(rational.Denominator))); }
private static int GetChangedNumerator(Rational rational, int commonDenominator) { return(rational.Numerator * (commonDenominator / rational.Denominator)); }
private static bool CheckArgumetIsNaN(Rational r1, Rational r2) { return(r1.IsNan || r2.IsNan); }
public void ConvertToDouble() { double v = new Rational(1, 2); Assert.AreEqual(0.5, v, 1e-7); }
public void Equal(int numerator, int denominator, Rational b) { Assert.False(b.IsNan); Assert.AreEqual(numerator, b.Numerator); Assert.AreEqual(denominator, b.Denominator); }