Example #1
0
        /// <summary>
        /// Умножение дробей
        /// </summary>
        /// <param name="x"></param>
        /// <returns></returns>
        public Fraction Multi(Fraction x)
        {
            Fraction y = new Fraction();

            y.denominator = this.denominator * x.denominator;
            y.numerator   = this.numerator * x.numerator;

            y.Simplification();
            return(y);
        }
Example #2
0
        /// <summary>
        /// Деление дробей
        /// </summary>
        /// <param name="x"></param>
        /// <returns></returns>
        public Fraction Divide(Fraction x)
        {
            Fraction y = new Fraction();

            y.denominator = x.numerator;
            y.numerator   = x.denominator;

            Fraction result = this.Multi(y);

            result.Simplification();
            return(result);
        }
Example #3
0
        /// <summary>
        /// Вычитание дробей
        /// </summary>
        /// <param name="x"></param>
        /// <returns></returns>
        public Fraction Minus(Fraction x)
        {
            Fraction y = new Fraction();

            if (this.denominator == x.denominator)
            {
                y.denominator = this.denominator;
                y.numerator   = this.numerator - x.numerator;
            }
            else
            {
                y.denominator = this.denominator * x.denominator;
                y.numerator   = this.numerator * x.denominator - x.numerator * this.denominator;
            }

            y.Simplification();

            return(y);
        }