예제 #1
0
        public int CompareTo(BigFloat other)
        {
            if (object.Equals(other, null))
            {
                throw new ArgumentNullException(nameof(other));
            }

            //Make copies
            var one = Numerator;
            var two = other.Numerator;

            //cross multiply
            one *= other.Denominator;
            two *= Denominator;

            //test
            return(BigInteger.Compare(one, two));
        }
예제 #2
0
        public int CompareTo(BigFloat other)
        {
            if (BigFloat.Equals(other, null))
            {
                throw new ArgumentNullException("other");
            }

            //Make copies
            BigInteger one = this.numerator;
            BigInteger two = other.numerator;

            //cross multiply
            one *= other.denominator;
            two *= this.denominator;

            //test
            return(BigInteger.Compare(one, two));
        }
예제 #3
0
 public static int Compare(BigRational r1, BigRational r2)
 {
     //     a/b = c/d, iff ad = bc
     return BigInteger.Compare(r1.m_numerator * r2.Denominator, r2.m_numerator * r1.Denominator);
 }