Exemplo n.º 1
0
        public static SimpleFraction ReductionDenominator(SimpleFraction fraction, int denominator)
        {
            CheckMaxMinForMultiplication(fraction.Numerator, denominator);
            CheckMaxMinForMultiplication(fraction.Denominator, denominator);
            int            fractionNumerator   = fraction.Numerator * denominator;
            int            fractionDenominator = fraction.Denominator * denominator;
            SimpleFraction resultFraction      = new SimpleFraction(0, 1);

            resultFraction.Numerator   = fractionNumerator;
            resultFraction.Denominator = fractionDenominator;
            return(resultFraction);
        }
Exemplo n.º 2
0
        public static SimpleFraction operator /(SimpleFraction leftFraction, SimpleFraction rightFraction)
        {
            CheckMaxMinForMultiplication(leftFraction.Numerator, rightFraction.Numerator);
            CheckMaxMinForMultiplication(leftFraction.Denominator, rightFraction.Numerator);
            if (rightFraction.Numerator == 0)
            {
                throw new ArgumentNullException("rightFraction.Numerator", "На нулевую дробь делить нельзя");
            }
            SimpleFraction ResultFraction = new SimpleFraction(leftFraction.Numerator * rightFraction.Denominator, leftFraction.Denominator * rightFraction.Numerator);

            return(ReductionFraction(ResultFraction));
        }