protected override IDataItem TestFunc(IDataItem p1, IDataItem p2) { var u = p1.ToUInt32().Value; var v = p2.ToRational().Value; var w = Rational.Compare(u, v); return(new Int32DataItem(w)); }
public void Case1() { Rational number1, number2; bool succeeded1, succeeded2; (succeeded1, number1) = Rational.TryParse("-12347534159895123"); (succeeded2, number2) = Rational.TryParse("987654321357159852"); if (succeeded1 && succeeded2) { number1 *= 3; number2 *= 2; switch (Rational.Compare(number1, number2)) { case -1: Console.WriteLine("{0} is greater than {1}.", number2, number1); break; case 0: Console.WriteLine("{0} is equal to {1}.", number1, number2); break; case 1: Console.WriteLine("{0} is greater than {1}.", number1, number2); break; } } else { if (!succeeded1) { Console.WriteLine("Unable to initialize the first Rational value."); } if (!succeeded2) { Console.WriteLine("Unable to initialize the second Rational value."); } } // The example displays the following output: // 1975308642714319704 is greater than -37042602479685369. }
public void MinusT0_1F0_2() { Assert.AreEqual <int>(Rational.Compare(new Rational(true, new byte[] { 0 }, new byte[] { 1 }), new Rational(false, new byte[] { 0 }, new byte[] { 2 })), -1); }
public void PlusF1_1F1_1() { Assert.AreEqual <int>(Rational.Compare(new Rational(false, new byte[] { 1 }, new byte[] { 1 }), new Rational(false, new byte[] { 1 }, new byte[] { 2 })), 1); }
public void ZeroT2_2T1_1() { Assert.AreEqual <int>(Rational.Compare(new Rational(true, new byte[] { 2 }, new byte[] { 2 }), new Rational(true, new byte[] { 1 }, new byte[] { 1 })), 0); }
public void ZeroT0_1T0_2() { Assert.AreEqual <int>(Rational.Compare(new Rational(true, new byte[] { 0 }, new byte[] { 1 }), new Rational(true, new byte[] { 0 }, new byte[] { 2 })), 0); }
public void ZeroF0_2F0_1() { Assert.AreEqual <int>(Rational.Compare(new Rational(false, new byte[] { 0 }, new byte[] { 2 }), new Rational(false, new byte[] { 0 }, new byte[] { 1 })), 0); }
public void UpperAreaMinus() { Assert.AreEqual <int>(Rational.Compare(CreateObjectCT(false, new ContainerType[] { 1, 0 }, new ContainerType[] { 1 }), CreateObjectCT(false, new ContainerType[] { 255 }, new ContainerType[] { 1 })), -1); }
public void NonPositiveInfinityPositiveInfinity() { Assert.AreEqual <int>(Rational.Compare(Rational.One, Rational.PositiveInfinity), -1); }
public void PositiveInfinityNonPositiveInfinity() { Assert.AreEqual <int>(Rational.Compare(Rational.PositiveInfinity, Rational.One), 1); }
public void PositiveInfinityPositiveInfinity() { Assert.AreEqual <int>(Rational.Compare(Rational.PositiveInfinity, Rational.PositiveInfinity), 0); }
public void NaNNaN() { Assert.AreEqual <int>(Rational.Compare(Rational.NaN, Rational.NaN), 0); }
public void NegativeInfinityNaN() { Assert.AreEqual <int>(Rational.Compare(Rational.NegativeInfinity, Rational.NaN), 1); }
public void NaNNegativeInfinity() { Assert.AreEqual <int>(Rational.Compare(Rational.NaN, Rational.NegativeInfinity), -1); }
public void MinusT1_1T1_2() { Assert.AreEqual <int>(Rational.Compare(new Rational(true, new byte[] { 1 }, new byte[] { 1 }), new Rational(true, new byte[] { 1 }, new byte[] { 2 })), -1); }
public void NonNegativeInfinityNegativeInfinity() { Assert.AreEqual <int>(Rational.Compare(Rational.One, Rational.NegativeInfinity), 1); }
public void PlusT1_2_T1_1() { Assert.AreEqual <int>(Rational.Compare(new Rational(true, new byte[] { 1 }, new byte[] { 2 }), new Rational(true, new byte[] { 1 }, new byte[] { 1 })), 1); }
public void RationalCompareNaN() { Rational.Compare(Rational.Zero, Rational.NaN); }
public void LowAreaZero() { Assert.AreEqual <int>(Rational.Compare(CreateObjectCT(false, new ContainerType[] { 255 }, new ContainerType[] { 1 }), CreateObjectCT(false, new ContainerType[] { 255, 0 }, new ContainerType[] { 1 })), 0); }