Ejemplo n.º 1
0
        public void ZeroTest()
        {
            var number        = 0.0f;
            var floatToString = Float754.FloatToString(number);

            Assert.AreEqual("0.00000000 * 2^(-126)", floatToString);
        }
Ejemplo n.º 2
0
        public void FloatToStringTest()
        {
            var number = 12.375f;
            var bits   = Float754.FloatToString(number);

            Assert.AreEqual("1.54687500 * 2^(3)", bits);
        }
Ejemplo n.º 3
0
        public void MinusOneTest()
        {
            var number        = -1.0f;
            var floatToString = Float754.FloatToString(number);

            Assert.AreEqual("-1.00000000 * 2^(0)", floatToString);
        }
Ejemplo n.º 4
0
        public void SmallTwoTest()
        {
            var number        = 1.6000001f;
            var floatToString = Float754.FloatToString(number);

            Assert.AreEqual("1.60000014 * 2^(0)", floatToString);
        }
Ejemplo n.º 5
0
        public void SmallestDenormalizedNumberSqrt()
        {
            var number = BitConverter.Int32BitsToSingle(0x00000001);

            Assert.AreEqual(1.40129846E-45f, number);
            var gama = Float754.FastSqrtFloat(number);

            Assert.AreEqual(8.01496461E-20f, gama);
        }
Ejemplo n.º 6
0
        public void NotANumberTest()
        {
            var number = float.NaN;

            Assert.IsTrue(float.IsNaN(number));
            var gama = Float754.FastSqrtFloat(number);

            Assert.AreEqual(6.65971189E-20f, gama);
        }
Ejemplo n.º 7
0
        public void LargestDenormalizedNumberSqrt()
        {
            var number = BitConverter.Int32BitsToSingle(0x007FFFFF);

            Assert.AreEqual(1.17549421E-38f, number);
            var gama = Float754.FastSqrtFloat(number);

            Assert.AreEqual(1.07254694E-19f, gama);
        }
Ejemplo n.º 8
0
        public void LargestNormalizedNumberSqrt()
        {
            var number = BitConverter.Int32BitsToSingle(0x7F7FFFFF);

            Assert.AreEqual(3.40282347E+38f, number);
            var gama = Float754.FastSqrtFloat(number);

            Assert.AreEqual(1.82484406E+19f, gama);
        }
Ejemplo n.º 9
0
        public void Sqrt1Test()
        {
            var number = 1.0f;

            Assert.AreEqual("1.00000000 * 2^(0)", Float754.FloatToString(number));
            var gama = Float754.FastSqrtFloat(number);

            Assert.AreEqual(1.0f, gama, 0.0108f);
        }
Ejemplo n.º 10
0
        public void SqrtHalfTest()
        {
            var number = 0.5f;

            Assert.AreEqual("1.00000000 * 2^(-1)", Float754.FloatToString(number));
            var gama = Float754.FastSqrtFloat(number);

            Assert.AreEqual(0.7071067811f, gama, 0.0322f);
        }
Ejemplo n.º 11
0
        public void Sqrt2Test()
        {
            var number = 2.0f;

            Assert.AreEqual("1.00000000 * 2^(1)", Float754.FloatToString(number));
            var gama = Float754.FastSqrtFloat(number);

            Assert.AreEqual(1.41421356237f, gama, 0.0643f);
        }
Ejemplo n.º 12
0
        public void SqrtOneSixteenthTest()
        {
            var number = 0.0625f;

            Assert.AreEqual("1.00000000 * 2^(-4)", Float754.FloatToString(number));
            var gama = Float754.FastSqrtFloat(number);

            Assert.AreEqual(0.25f, gama, 0.00269f);
        }
Ejemplo n.º 13
0
        public void SqrtQuarterTest()
        {
            var number = 0.25f;

            Assert.AreEqual("1.00000000 * 2^(-2)", Float754.FloatToString(number));
            var gama = Float754.FastSqrtFloat(number);

            Assert.AreEqual(0.5f, gama, 0.00538f);
        }
Ejemplo n.º 14
0
        public void Sqrt256Test()
        {
            var number = 256.0f;

            Assert.AreEqual("1.00000000 * 2^(8)", Float754.FloatToString(number));
            var gama = Float754.FastSqrtFloat(number);

            Assert.AreEqual(16.0f, gama, 0.173f);
        }
Ejemplo n.º 15
0
        public void MiddleDenormalizedNumberSqrt()
        {
            var number = BitConverter.Int32BitsToSingle(0x00400000);

            Assert.AreEqual(5.87747175E-39f, number);
            var gama = Float754.FastInvSqrtFloat(number);

            Assert.AreEqual(1.09343078E+19f, gama);
        }
Ejemplo n.º 16
0
        public void NotANumberTest()
        {
            var number = float.NaN;

            Assert.IsTrue(float.IsNaN(number));
            var floatToString = Float754.FloatToString(number);

            Assert.AreEqual("-1.50000000 * 2^(128)", floatToString);
        }
Ejemplo n.º 17
0
        public void MiddleDenormalizedNumberSqrt()
        {
            var number = BitConverter.Int32BitsToSingle(0x00400000);

            Assert.AreEqual(5.87747175E-39f, number);
            var gama = Float754.FastSqrtFloat(number);

            Assert.AreEqual(9.37021732E-20f, gama);
        }
Ejemplo n.º 18
0
        public void PositiveInfinityTest()
        {
            var number = float.PositiveInfinity;

            Assert.IsTrue(float.IsInfinity(number));
            var gama = Float754.FastInvSqrtFloat(number);

            Assert.AreEqual(5.24618333E-20f, gama);
        }
Ejemplo n.º 19
0
        public void NotANumberTest()
        {
            var number = float.NaN;

            Assert.IsTrue(float.IsNaN(number));
            var gama = Float754.FastInvSqrtFloat(number);

            Assert.AreEqual(1.55459938E+19f, gama);
        }
Ejemplo n.º 20
0
        public void LargestNormalizedNumberSqrt()
        {
            var number = BitConverter.Int32BitsToSingle(0x7F7FFFFF);

            Assert.AreEqual(3.40282347E+38f, number);
            var gama = Float754.FastInvSqrtFloat(number);

            Assert.AreEqual(5.24618366E-20f, gama);
        }
Ejemplo n.º 21
0
        public void Sqrt2Test()
        {
            var number = 2.0f;

            Assert.AreEqual("1.00000000 * 2^(1)", Float754.FloatToString(number));
            var gama = Float754.FastInvSqrtFloat(number);

            Assert.AreEqual(0.7071067811f, gama, 0.011f);
        }
Ejemplo n.º 22
0
        public void SqrtHalfTest()
        {
            var number = 0.5f;

            Assert.AreEqual("1.00000000 * 2^(-1)", Float754.FloatToString(number));
            var gama = Float754.FastInvSqrtFloat(number);

            Assert.AreEqual(1.414213562f, gama, 0.022f);
        }
Ejemplo n.º 23
0
        public void Sqrt4Test()
        {
            var number = 4.0f;

            Assert.AreEqual("1.00000000 * 2^(2)", Float754.FloatToString(number));
            var gama = Float754.FastSqrtFloat(number);

            Assert.AreEqual(2.0f, gama, 0.0216f);
        }
Ejemplo n.º 24
0
        public void PositiveInfinityTest()
        {
            var number = float.PositiveInfinity;

            Assert.IsTrue(float.IsInfinity(number));
            var gama = Float754.FastSqrtFloat(number);

            Assert.AreEqual(1.82484417E+19f, gama);
        }
Ejemplo n.º 25
0
        public void Sqrt16Test()
        {
            var number = 16.0f;

            Assert.AreEqual("1.00000000 * 2^(4)", Float754.FloatToString(number));
            var gama = Float754.FastSqrtFloat(number);

            Assert.AreEqual(4.0f, gama, 0.0431f);
        }
Ejemplo n.º 26
0
        public void SmallestNormalizedNumberSqrt()
        {
            var number = BitConverter.Int32BitsToSingle(0x00800000);

            Assert.AreEqual(1.17549435E-38f, number);
            var gama = Float754.FastSqrtFloat(number);

            Assert.AreEqual(1.072547E-19f, gama);
        }
Ejemplo n.º 27
0
        public void MiddleDenormalizedNumber()
        {
            var number = BitConverter.Int32BitsToSingle(0x00400000);

            Assert.IsFalse(float.IsNormal(number));
            Assert.AreEqual(5.87747175E-39f, number);
            var floatToString = Float754.FloatToString(number);

            Assert.AreEqual("0.50000000 * 2^(-126)", floatToString);
        }
Ejemplo n.º 28
0
        public void LargestDenormalizedNumber()
        {
            var number = BitConverter.Int32BitsToSingle(0x007FFFFF);

            Assert.IsFalse(float.IsNormal(number));
            Assert.AreEqual(1.17549421E-38f, number);
            var floatToString = Float754.FloatToString(number);

            Assert.AreEqual("0.99999988 * 2^(-126)", floatToString);
        }
Ejemplo n.º 29
0
        public void SmallestNormalizedNumber()
        {
            var number = BitConverter.Int32BitsToSingle(0x00800000);

            Assert.IsTrue(float.IsNormal(number));
            Assert.AreEqual(1.17549435E-38f, number);
            var floatToString = Float754.FloatToString(number);

            Assert.AreEqual("1.00000000 * 2^(-126)", floatToString);
        }
Ejemplo n.º 30
0
        public void NegativeZeroTest()
        {
            // 0x8000_0000
            var number = BitConverter.Int32BitsToSingle(-2_147_483_648);

            Assert.AreEqual(0.0f, number);
            var floatToString = Float754.FloatToString(number);

            Assert.AreEqual("-0.00000000 * 2^(-126)", floatToString);
        }