Example #1
0
 public void RationalCanonicalize()
 {
     using (var a = new HugeRational(198, 15))
     {
         a.Denominator.Value = -a.Denominator;
         Assert.AreEqual("198/-15", a.ToString());
         a.Canonicalize();
         Assert.AreEqual("-66/5", a.ToString());
     }
 }
 public void RationalCanonicalize()
 {
     using (var a = new HugeRational(198, 15))
     {
         a.Denominator.Value = -a.Denominator;
         Assert.AreEqual("198/-15", a.ToString());
         a.Canonicalize();
         Assert.AreEqual("-66/5", a.ToString());
     }
 }
Example #3
0
 public void RationalDivideHugeInt()
 {
     using (var a = new HugeRational("222509832503450298345029835740293845720/115756986668303657898962467957"))
         using (var b = new HugeInt("222987435987982730594288574029879874539"))
             using (var c = new HugeRational(a / b))
                 using (var d = new HugeRational())
                 {
                     Assert.AreEqual(a.Numerator, c.Numerator);
                     Assert.AreEqual(a.Denominator * b, c.Denominator);
                     c.Value             = (b + 1) / a;
                     d.Numerator.Value   = (b + 1) * a.Denominator;
                     d.Denominator.Value = a.Numerator;
                     d.Canonicalize();
                     Assert.AreEqual(d, c);
                 }
 }
Example #4
0
 public void RationalDivideHugeInt()
 {
     using (var a = new HugeRational("222509832503450298345029835740293845720/115756986668303657898962467957"))
     using (var b = new HugeInt("222987435987982730594288574029879874539"))
     using (var c = new HugeRational(a / b))
     using (var d = new HugeRational())
     {
         Assert.AreEqual(a.Numerator, c.Numerator);
         Assert.AreEqual(a.Denominator * b, c.Denominator);
         c.Value = (b + 1) / a;
         d.Numerator.Value = (b + 1) * a.Denominator;
         d.Denominator.Value = a.Numerator;
         d.Canonicalize();
         Assert.AreEqual(d, c);
     }
 }