Esempio n. 1
0
        public override bool Equals(object obj)
        {
            if (!(obj is BigFraction))
            {
                return(false);
            }

            BigFraction bf1 = this;
            BigFraction bf2 = (BigFraction)obj;

            return(bf1.Numerator == bf2.Numerator);
        }
        public override bool Equals(object obj)
        {
            if (!(obj is BigFraction))
            {
                return(false);
            }

            BigFraction bf1 = this;
            BigFraction bf2 = (BigFraction)obj;

            ToSameDenominator(ref bf1, ref bf2);

            return(bf1.Numerator == bf2.Numerator);
        }
        private static void ToSameDenominator(ref BigFraction bf1, ref BigFraction bf2)
        {
            if (bf1.Denominator == bf2.Denominator)
            {
                return;
            }

            BigInteger denominator1 = bf1.Denominator;
            BigInteger denominator2 = bf2.Denominator;
            BigInteger denominator  = bf1.Denominator * bf2.Denominator;

            bf1 = new BigFraction(bf1.Numerator * denominator2, denominator);
            bf2 = new BigFraction(bf2.Numerator * denominator1, denominator);
        }