public Rational(int numerator, int denominator) { if (denominator < 1) { throw new ArgumentException("denominator must be positive.", "denominator"); } int gcd = Functions.GCD(numerator, denominator); Numerator = numerator / gcd; Denominator = denominator / gcd; }
private Rational(int numerator, int denominator, bool normalize) { if (denominator < 1) { throw new ArgumentException("denominator must be positive.", "denominator"); } if (normalize) { int gcd = Functions.GCD(numerator, denominator); Numerator = numerator / gcd; Denominator = denominator / gcd; } else { Numerator = numerator; Denominator = denominator; } }