Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
        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;
            }
        }