コード例 #1
0
        public bool CanFitInSingle(object obj)
        {
            var ef = (EFloat)obj;

            return((!ef.IsFinite) ||
                   (ef.CompareTo(EFloat.FromSingle(ef.ToSingle())) == 0));
        }
コード例 #2
0
        public bool CanFitInSingle(object obj)
        {
            var    bigintItem = (EInteger)obj;
            EFloat ef         = EFloat.FromEInteger(bigintItem);
            EFloat ef2        = EFloat.FromSingle(ef.ToSingle());

            return(ef.CompareTo(ef2) == 0);
        }
コード例 #3
0
ファイル: ExtraTest.cs プロジェクト: ulfendk/Numbers
        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()));
        }
コード例 #4
0
ファイル: CBORUtilities.cs プロジェクト: tspannhw/CBOR
 public static string SingleToString(float sing)
 {
     return(EFloat.FromSingle(sing).ToShortestString(EContext.Binary32));
 }
コード例 #5
0
 public EFloat AsExtendedFloat(object obj)
 {
     return(EFloat.FromSingle((float)obj));
 }