Esempio n. 1
0
        public int CompareTo(BigInteger other)
        {
            BigInteger n1 = this.Top;
            BigInteger n2 = this.Bottom * other;

            return(n1.CompareTo(n2));
        }
Esempio n. 2
0
        public int CompareTo(Rational other)
        {
            BigInteger n1 = this.Top * other.Bottom;
            BigInteger n2 = this.Bottom * other.Top;

            return(n1.CompareTo(n2));
        }
Esempio n. 3
0
 public int CompareTo(XYTerm other)
 {
     if (XPower != other.XPower)
     {
         return(XPower.CompareTo(other.XPower));
     }
     return(YPower.CompareTo(other.YPower));
 }
Esempio n. 4
0
        public int CompareTo(BigFloat that)
        {
            Contract.Requires(exponentSize == that.exponentSize);
            Contract.Requires(significandSize == that.significandSize);

            if (value == "" && that.value == "")
            {
                int cmpThis = IsZero ? 0 : isSignBitSet ? -1 : 1;
                int cmpThat = that.IsZero ? 0 : that.isSignBitSet ? -1 : 1;

                if (cmpThis == cmpThat)
                {
                    if (exponent == that.exponent)
                    {
                        return(cmpThis * significand.CompareTo(that.significand));
                    }

                    return(cmpThis * exponent.CompareTo(that.exponent));
                }

                if (cmpThis == 0)
                {
                    return(-cmpThat);
                }

                return(cmpThis);
            }

            if (value == that.value)
            {
                return(0);
            }

            if (value == "NaN" || that.value == "+oo" || value == "-oo" && that.value != "NaN")
            {
                return(-1);
            }

            return(1);
        }
Esempio n. 5
0
 // Check coefficient c is a valid element in ECField field.
 private static void CheckValidity(ECField field, System.Numerics.BigInteger c, String cName)
 {
     // can only perform check if field is ECFieldFp or ECFieldF2m.
     if (field is ECFieldFp)
     {
         System.Numerics.BigInteger p = ((ECFieldFp)field).P;
         if (p.CompareTo(c) != 1)
         {
             throw new IllegalArgumentException(cName + " is too large");
         }
         else if (c.signum() < 0)
         {
             throw new IllegalArgumentException(cName + " is negative");
         }
     }
     else if (field is ECFieldF2m)
     {
         int m = ((ECFieldF2m)field).M;
         if (c.bitLength() > m)
         {
             throw new IllegalArgumentException(cName + " is too large");
         }
     }
 }
Esempio n. 6
0
 public int CompareTo(PathFinderNode Other)
 {
     return(Cost.CompareTo(Other.Cost));
 }
Esempio n. 7
0
 public void CompareTo()
 {
     var a = new BigInteger(99);
     Assert.AreEqual(-1, a.CompareTo(100), "#1");
     Assert.AreEqual(1, a.CompareTo(null), "#2");
 }
Esempio n. 8
0
        public void CompareLong()
        {
            long[] values = { -100000000000L, -1000, -1, 0, 1, 1000, 9999999, 100000000000L, 0xAA00000000, long.MaxValue, long.MinValue };

            for (var i = 0; i < values.Length; ++i)
            {
                for (var j = 0; j < values.Length; ++j)
                {
                    var a = new BigInteger(values[i]);
                    var b = values[j];
                    var c = new BigInteger(b);

                    Assert.AreEqual(a.CompareTo(c), a.CompareTo(b), "#a_" + i + "_" + j);

                    Assert.AreEqual(a > c, a > b, "#b_" + i + "_" + j);
                    Assert.AreEqual(a < c, a < b, "#c_" + i + "_" + j);
                    Assert.AreEqual(a <= c, a <= b, "#d_" + i + "_" + j);
                    Assert.AreEqual(a == c, a == b, "#e_" + i + "_" + j);
                    Assert.AreEqual(a != c, a != b, "#f_" + i + "_" + j);
                    Assert.AreEqual(a >= c, a >= b, "#g_" + i + "_" + j);

                    Assert.AreEqual(c > a, b > a, "#ib_" + i + "_" + j);
                    Assert.AreEqual(c < a, b < a, "#ic_" + i + "_" + j);
                    Assert.AreEqual(c <= a, b <= a, "#id_" + i + "_" + j);
                    Assert.AreEqual(c == a, b == a, "#ie_" + i + "_" + j);
                    Assert.AreEqual(c != a, b != a, "#if_" + i + "_" + j);
                    Assert.AreEqual(c >= a, b >= a, "#ig_" + i + "_" + j);
                }
            }
        }
Esempio n. 9
0
        public void CompareOps2()
        {
            var a = new BigInteger(100000000000L);
            var b = new BigInteger(28282828282UL);

            Assert.IsTrue(a >= b, "#1");
            Assert.IsTrue(a >= b, "#2");
            Assert.IsFalse(a < b, "#3");
            Assert.IsFalse(a <= b, "#4");
            Assert.AreEqual(1, a.CompareTo(b), "#5");
        }
Esempio n. 10
0
        public void CompareOps()
        {
            long[] values = { -100000000000L, -1000, -1, 0, 1, 1000, 100000000000L };

            for (var i = 0; i < values.Length; ++i)
            {
                for (var j = 0; j < values.Length; ++j)
                {
                    var a = new BigInteger(values[i]);
                    var b = new BigInteger(values[j]);

                    Assert.AreEqual(values[i].CompareTo(values[j]), a.CompareTo(b), "#a_" + i + "_" + j);
                    Assert.AreEqual(values[i].CompareTo(values[j]), BigInteger.Compare(a, b), "#b_" + i + "_" + j);

                    Assert.AreEqual(values[i] < values[j], a < b, "#c_" + i + "_" + j);
                    Assert.AreEqual(values[i] <= values[j], a <= b, "#d_" + i + "_" + j);
                    Assert.AreEqual(values[i] == values[j], a == b, "#e_" + i + "_" + j);
                    Assert.AreEqual(values[i] != values[j], a != b, "#f_" + i + "_" + j);
                    Assert.AreEqual(values[i] >= values[j], a >= b, "#g_" + i + "_" + j);
                    Assert.AreEqual(values[i] > values[j], a > b, "#h_" + i + "_" + j);
                }
            }
        }
Esempio n. 11
0
 public int CompareTo(XTerm other)
 {
     return(XPower.CompareTo(other.XPower));
 }