public static void TestStringEqualRoundTrip(EFloat obj) { Assert.AreEqual( EDecimal.PositiveInfinity, EDecimal.FromSingle(Single.PositiveInfinity)); Assert.AreEqual( EDecimal.NegativeInfinity, EDecimal.FromSingle(Single.NegativeInfinity)); Assert.AreEqual( EFloat.PositiveInfinity, EFloat.FromDouble(Double.PositiveInfinity)); Assert.AreEqual( EFloat.NegativeInfinity, EFloat.FromDouble(Double.NegativeInfinity)); Assert.AreEqual( EFloat.PositiveInfinity, EFloat.FromSingle(Single.PositiveInfinity)); Assert.AreEqual( EFloat.NegativeInfinity, EFloat.FromSingle(Single.NegativeInfinity)); Assert.AreEqual( ERational.PositiveInfinity, ERational.FromDouble(Double.PositiveInfinity)); Assert.AreEqual( ERational.NegativeInfinity, ERational.FromDouble(Double.NegativeInfinity)); Assert.AreEqual( ERational.PositiveInfinity, ERational.FromSingle(Single.PositiveInfinity)); Assert.AreEqual( ERational.NegativeInfinity, ERational.FromSingle(Single.NegativeInfinity)); Assert.AreEqual( ERational.PositiveInfinity, ERational.FromEDecimal(EDecimal.PositiveInfinity)); Assert.AreEqual( ERational.NegativeInfinity, ERational.FromEDecimal(EDecimal.NegativeInfinity)); Assert.AreEqual( ERational.PositiveInfinity, ERational.FromEFloat(EFloat.PositiveInfinity)); Assert.AreEqual( ERational.NegativeInfinity, ERational.FromEFloat(EFloat.NegativeInfinity)); Assert.IsTrue(Double.IsPositiveInfinity(ERational.PositiveInfinity.ToDouble())); Assert.IsTrue(Double.IsNegativeInfinity(ERational.NegativeInfinity.ToDouble())); Assert.IsTrue(Single.IsPositiveInfinity(ERational.PositiveInfinity.ToSingle())); Assert.IsTrue(Single.IsNegativeInfinity(ERational.NegativeInfinity.ToSingle())); }
public void TestToDouble() { // test for correct rounding double dbl; dbl = ERational.FromEDecimal( EDecimal.FromString( "1.972579273363468721491642554610734805464744567871093749999999999999")) .ToDouble(); { string stringTemp = EFloat.FromDouble(dbl).ToPlainString(); Assert.AreEqual( "1.9725792733634686104693400920950807631015777587890625", stringTemp); } }
public void TestCompareToDecimal() { var fr = new RandomGenerator(); for (var i = 0; i < 100; ++i) { ERational er = RandomObjects.RandomERational(fr); int exp = -100000 + fr.UniformInt(200000); EDecimal ed = EDecimal.Create( RandomObjects.RandomEInteger(fr), (EInteger)exp); ERational er2 = ERational.FromEDecimal(ed); int c2r = er.CompareTo(er2); int c2d = er.CompareToDecimal(ed); Assert.AreEqual(c2r, c2d); } }
public ERational AsERational(object obj) { return(ERational.FromEDecimal((EDecimal)obj)); }