Пример #1
0
 public void IntEqualsDouble()
 {
     using (var a = new HugeInt("-222509832505"))
     {
         double b = -222509832504;
         Assert.IsFalse(a.Equals(b + 1));
         Assert.IsTrue(a.Equals(b - 1));
         Assert.IsTrue((a + 1).Equals(b));
         Assert.IsFalse((a + 1).Equals(b + 0.1));
     }
 }
Пример #2
0
        public void IntEqualsSignedLimb()
        {
            var source = Platform.Select("-222509832505", "-225032505");
            var b      = Platform.Si(-222509832504, -225032504);

            using (var a = new HugeInt(source))
            {
                Assert.IsFalse(a.Equals(b + 1));
                Assert.IsTrue(a.Equals(b - 1));
                Assert.IsTrue((a + 1).Equals(b));
            }
        }
Пример #3
0
        public void IntEqualsLimb()
        {
            var source = Platform.Select("222509832503", "2225032503");
            var b      = Platform.Ui(222509832504, 2225032504);

            using (var a = new HugeInt(source))
            {
                Assert.IsFalse(a.Equals(b + 1));
                Assert.IsTrue(a.Equals(b - 1));
                Assert.IsTrue((a + 1).Equals(b));
            }
        }
Пример #4
0
 public void IntEqualsHugeInt()
 {
     using (var a = new HugeInt("-222509832503450298345029835740293845721"))
         using (var b = new HugeInt("222509832503450298345029835740293845720"))
         {
             Assert.IsFalse(b.Equals(a));
             Assert.IsFalse(a.Equals(b + 1));
             Assert.IsTrue((a + 1).Equals(-b));
             Assert.IsFalse(a.Equals(null));
             Assert.IsTrue(Equals(a + 1, -b));
         }
 }
Пример #5
0
 public void IntEqualsNonExpression()
 {
     using (var a = new HugeInt("-222509832503450298345029835740293845721"))
     {
         Assert.IsFalse(a.Equals("abc"));
     }
 }
Пример #6
0
 public void RationalEqualsHugeInt()
 {
     using (var a = new HugeRational("-222509832503450298345029835740293845721/115756986668303657898962467957"))
         using (var b = new HugeInt(1922215142))
             using (var c = new HugeRational("115756986668303657898962467957/1"))
                 using (var d = new HugeInt("-115756986668303657898962467957"))
                 {
                     Assert.IsFalse(a.Equals(b));
                     Assert.IsFalse(b.Equals(a));
                     Assert.IsFalse(a.Equals(-b));
                     Assert.IsFalse(b.Equals(-a));
                     Assert.IsFalse(c.Equals(d));
                     Assert.IsTrue(c.Equals(-d));
                     Assert.IsTrue((-c).Equals(d));
                     Assert.IsTrue(d.Equals(-c));
                     Assert.IsTrue((-d).Equals(c));
                     Assert.IsTrue(Equals(c, -d));
                     Assert.IsTrue(Equals(-c, d));
                 }
 }
Пример #7
0
 public void RationalEqualsHugeInt()
 {
     using (var a = new HugeRational("-222509832503450298345029835740293845721/115756986668303657898962467957"))
     using (var b = new HugeInt(1922215142))
     using (var c = new HugeRational("115756986668303657898962467957/1"))
     using (var d = new HugeInt("-115756986668303657898962467957"))
     {
         Assert.IsFalse(a.Equals(b));
         Assert.IsFalse(b.Equals(a));
         Assert.IsFalse(a.Equals(-b));
         Assert.IsFalse(b.Equals(-a));
         Assert.IsFalse(c.Equals(d));
         Assert.IsTrue(c.Equals(-d));
         Assert.IsTrue((-c).Equals(d));
         Assert.IsTrue(d.Equals(-c));
         Assert.IsTrue((-d).Equals(c));
         Assert.IsTrue(Equals(c, -d));
         Assert.IsTrue(Equals(-c, d));
     }
 }