예제 #1
0
 public void RationalEqualsLimb()
 {
     using (var a = new HugeRational(Platform.Select("222509832503", "2225098323")))
     {
         var b = Platform.Ui(222509832504, 2225098324);
         Assert.IsFalse(a.Equals(b + 1));
         Assert.IsTrue(a.Equals(b - 1));
         Assert.IsTrue((a + 1).Equals(b));
     }
 }
예제 #2
0
 public void RationalEqualsSignedLimb()
 {
     using (var a = new HugeRational(Platform.Select("-222509832505", "-222509835")))
     {
         var b = Platform.Si(-222509832504, -222509834);
         Assert.IsFalse(a.Equals(b + 1));
         Assert.IsTrue(a.Equals(b - 1));
         Assert.IsTrue((a + 1).Equals(b));
     }
 }
예제 #3
0
 public void RationalEqualsLimb2()
 {
     using (var a = new HugeRational(Platform.Select("222509832377/127", "2509832377/127")))
     {
         var  b = Platform.Ui(222509832504, 2509832504);
         uint d = 127;
         Assert.IsFalse(a.Equals(b + 1, d));
         Assert.IsTrue(a.Equals(b - d, d));
         Assert.IsTrue((a + 1).Equals(b, d));
     }
 }
예제 #4
0
 public void RationalEqualsSignedLimb2()
 {
     using (var a = new HugeRational(Platform.Select("-222509832377/127", "-1509832377/127")))
     {
         var  b = Platform.Si(-222509832504, -1509832504);
         uint d = 127;
         Assert.IsFalse(a.Equals(b + 1, d));
         Assert.IsTrue(a.Equals(b + (int)d, d));
         Assert.IsTrue((a - 1).Equals(b, d));
     }
 }
예제 #5
0
 public void RationalEqualsDouble()
 {
     using (var a = new HugeRational("-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));
     }
 }
예제 #6
0
 public void RationalEqualsHugeRational()
 {
     using (var a = new HugeRational("-222509832503450298345029835740293845721/115756986668303657898962467957"))
         using (var b = new HugeRational("222509832503450298345029835740293845720/115756986668303657898962467957"))
             using (var c = new HugeRational("1/115756986668303657898962467957"))
             {
                 Assert.IsFalse(b.Equals(a));
                 Assert.IsFalse(a.Equals(b + c));
                 Assert.IsTrue((a + c).Equals(-b));
                 Assert.IsFalse(a.Equals(null));
                 Assert.IsTrue(Equals(a + c, -b));
             }
 }
예제 #7
0
 public void RationalEqualsNonExpression()
 {
     using (var a = new HugeRational("-222509832503450298345029835740293845721/115756986668303657898962467957"))
     {
         Assert.IsFalse(a.Equals("abc"));
     }
 }
예제 #8
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));
                 }
 }
예제 #9
0
        public void RationalToAndFromDouble()
        {
            using (var a = new HugeRational())
            {
                a.SetTo(-123.25);

                double c = a.ToDouble();
                Assert.IsTrue(c.Equals(-123.25));
                Assert.IsTrue(a.Equals(-123.25));
            }
        }
예제 #10
0
 public void RationalEqualsSignedLimb()
 {
     using (var a = new HugeRational(Platform.Select("-222509832505", "-222509835")))
     {
         var b = Platform.Si(-222509832504, -222509834);
         Assert.IsFalse(a.Equals(b + 1));
         Assert.IsTrue(a.Equals(b - 1));
         Assert.IsTrue((a + 1).Equals(b));
     }
 }
예제 #11
0
 public void RationalEqualsSignedLimb2()
 {
     using (var a = new HugeRational(Platform.Select("-222509832377/127", "-1509832377/127")))
     {
         var b = Platform.Si(-222509832504, -1509832504);
         uint d = 127;
         Assert.IsFalse(a.Equals(b + 1, d));
         Assert.IsTrue(a.Equals(b + (int)d, d));
         Assert.IsTrue((a - 1).Equals(b, d));
     }
 }
예제 #12
0
 public void RationalEqualsLimb2()
 {
     using (var a = new HugeRational(Platform.Select("222509832377/127", "2509832377/127")))
     {
         var b = Platform.Ui(222509832504, 2509832504);
         uint d = 127;
         Assert.IsFalse(a.Equals(b + 1, d));
         Assert.IsTrue(a.Equals(b - d, d));
         Assert.IsTrue((a + 1).Equals(b, d));
     }
 }
예제 #13
0
 public void RationalEqualsNonExpression()
 {
     using (var a = new HugeRational("-222509832503450298345029835740293845721/115756986668303657898962467957"))
     {
         Assert.IsFalse(a.Equals("abc"));
     }
 }
예제 #14
0
 public void RationalEqualsLimb()
 {
     using (var a = new HugeRational(Platform.Select("222509832503", "2225098323")))
     {
         var b = Platform.Ui(222509832504, 2225098324);
         Assert.IsFalse(a.Equals(b + 1));
         Assert.IsTrue(a.Equals(b - 1));
         Assert.IsTrue((a + 1).Equals(b));
     }
 }
예제 #15
0
 public void RationalEqualsHugeRational()
 {
     using (var a = new HugeRational("-222509832503450298345029835740293845721/115756986668303657898962467957"))
     using (var b = new HugeRational("222509832503450298345029835740293845720/115756986668303657898962467957"))
     using (var c = new HugeRational("1/115756986668303657898962467957"))
     {
         Assert.IsFalse(b.Equals(a));
         Assert.IsFalse(a.Equals(b + c));
         Assert.IsTrue((a + c).Equals(-b));
         Assert.IsFalse(a.Equals(null));
         Assert.IsTrue(Equals(a + c, -b));
     }
 }
예제 #16
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));
     }
 }
예제 #17
0
 public void RationalEqualsDouble()
 {
     using (var a = new HugeRational("-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));
     }
 }
예제 #18
0
        public void RationalToAndFromDouble()
        {
            using (var a = new HugeRational())
            {
                a.SetTo(-123.25);

                double c = a.ToDouble();
                Assert.IsTrue(c.Equals(-123.25));
                Assert.IsTrue(a.Equals(-123.25));
            }
        }