Example #1
0
        //public Fraction Add(Fraction a)
        //{
        //	return Add(this, a);
        //}

        //public static Fraction operator +(Fraction a, Fraction b)
        //{
        //	return a.Add(b);
        //}

        public static Fraction operator -(Fraction a, Fraction b)
        {
            Fraction result = new Fraction();

            QuyDong(a, b);
            result.numerator   = a.numerator - b.numerator;
            result.denominator = a.denominator;
            result.RutGon();
            return(result);
        }
Example #2
0
        //public Fraction Multi(Fraction a)
        //{
        //	return Multi(this, a);
        //}

        //public static Fraction operator *(Fraction a, Fraction b)
        //{
        //	return a.Multi(b);
        //}

        public static Fraction operator /(Fraction a, Fraction b)
        {
            Fraction result = new Fraction();

            a.RutGon();
            b.RutGon();
            result.numerator   = a.numerator * b.denominator;
            result.denominator = Math.Abs(a.denominator * b.numerator);
            result.RutGon();
            return(result);
        }
Example #3
0
        public Fraction FindMax()
        {
            Fraction max = a[0];

            for (int i = 1; i < length; i++)
            {
                //float x = max.numerator * a[i].denominator;
                //float y = a[i].numerator * max.denominator;
                //if (x < y)
                //	max = a[i];

                //if (CompareTwoFractions(max, a[i]) < 0)
                if (max.CompareTwoFractions(a[i]) < 0)
                {
                    max = a[i];
                }
            }
            max.RutGon();
            return(max);
        }
Example #4
0
        public Fraction FindMin()
        {
            //int x, y;
            Fraction min = a[0];

            for (int i = 1; i < length; i++)
            {
                //x = min.numerator * a[i].denominator;
                //y = a[i].numerator * min.denominator;
                //if (x > y)
                //	min = a[i];

                //if (CompareTwoFractions(max, a[i]) > 0)
                if (min.CompareTwoFractions(a[i]) > 0)
                {
                    min = a[i];
                }
            }
            min.RutGon();
            return(min);
        }