コード例 #1
0
 public void TestExactrationalConstruction()
 {
     {
         OrderedField a = ExactRational.ConstructExactRational(1, 2);
         print(a);
         a = ExactRational.ConstructExactRational(2, 6);
         print(a);
         a = ExactRational.ConstructExactRational(-2, 8);
         print(a);
         Assert.IsTrue(a.IsNegative());
     }
 }
コード例 #2
0
 public void TestComputationOfExactRational()
 {
     print("Trying to compute 1/2 * 1/2 = 1/4");
     {
         var a = ExactRational.ConstructExactRational(1, 2);
         var b = ExactRational.ConstructExactRational(1, 2);
         Assert.IsTrue((a * b) == ExactRational.ConstructExactRational(1, 4));
     }
     print("Trying to compute 7/8 * 8/7 = 1");
     {
         var a = ExactRational.ConstructExactRational(7, 8);
         Assert.IsTrue(
             a.MultiplicativeInverse() * a == ExactRational.ConstructExactRational(1, 1));
     }
 }