Пример #1
0
        public void ZeroTest()
        {
            var number         = 0.0;
            var doubleToString = Double754.DoubleToString(number);

            Assert.AreEqual("0.0000000000000000 * 2^(-1022)", doubleToString);
        }
Пример #2
0
        public void SmallTwoTest()
        {
            var number         = 1.600000000000001;
            var doubleToString = Double754.DoubleToString(number);

            Assert.AreEqual("1.6000000000000010 * 2^(0)", doubleToString);
        }
Пример #3
0
        public void DoubleToStringTest()
        {
            var number = 12.375;
            var bits   = Double754.DoubleToString(number);

            Assert.AreEqual("1.5468750000000000 * 2^(3)", bits);
        }
Пример #4
0
        public void Sqrt16Test()
        {
            var number = 16.0;

            Assert.AreEqual("1.0000000000000000 * 2^(4)", Double754.DoubleToString(number));
            var gama = Double754.FastSqrtDouble(number);

            Assert.AreEqual(4.0, gama, 0.0431);
        }
Пример #5
0
        public void Sqrt256Test()
        {
            var number = 256.0;

            Assert.AreEqual("1.0000000000000000 * 2^(8)", Double754.DoubleToString(number));
            var gama = Double754.FastSqrtDouble(number);

            Assert.AreEqual(16.0, gama, 0.173);
        }
Пример #6
0
        public void Sqrt2Test()
        {
            var number = 2.0;

            Assert.AreEqual("1.0000000000000000 * 2^(1)", Double754.DoubleToString(number));
            var gama = Double754.FastSqrtDouble(number);

            Assert.AreEqual(1.4142135623730950488016887242097, gama, 0.0643);
        }
Пример #7
0
        public void Sqrt1Test()
        {
            var number = 1.0;

            Assert.AreEqual("1.0000000000000000 * 2^(0)", Double754.DoubleToString(number));
            var gama = Double754.FastSqrtDouble(number);

            Assert.AreEqual(1.0, gama, 0.0108);
        }
Пример #8
0
        public void SqrtHalfTest()
        {
            var number = 0.5;

            Assert.AreEqual("1.0000000000000000 * 2^(-1)", Double754.DoubleToString(number));
            var gama = Double754.FastInvSqrtDouble(number);

            Assert.AreEqual(1.414213562, gama, 0.022);
        }
Пример #9
0
        public void SqrtQuarterTest()
        {
            var number = 0.25;

            Assert.AreEqual("1.0000000000000000 * 2^(-2)", Double754.DoubleToString(number));
            var gama = Double754.FastSqrtDouble(number);

            Assert.AreEqual(0.5, gama, 0.00538);
        }
Пример #10
0
        public void SqrtHalfTest()
        {
            var number = 0.5;

            Assert.AreEqual("1.0000000000000000 * 2^(-1)", Double754.DoubleToString(number));
            var gama = Double754.FastSqrtDouble(number);

            Assert.AreEqual(0.70710678118654752440084436210485, gama, 0.0322);
        }
Пример #11
0
        public void Sqrt2Test()
        {
            var number = 2.0;

            Assert.AreEqual("1.0000000000000000 * 2^(1)", Double754.DoubleToString(number));
            var gama = Double754.FastInvSqrtDouble(number);

            Assert.AreEqual(0.7071067811, gama, 0.011);
        }
Пример #12
0
        public void SqrtOneSixteenthTest()
        {
            var number = 0.0625;

            Assert.AreEqual("1.0000000000000000 * 2^(-4)", Double754.DoubleToString(number));
            var gama = Double754.FastSqrtDouble(number);

            Assert.AreEqual(0.25, gama, 0.00269);
        }
Пример #13
0
        public void Sqrt4Test()
        {
            var number = 4.0;

            Assert.AreEqual("1.0000000000000000 * 2^(2)", Double754.DoubleToString(number));
            var gama = Double754.FastSqrtDouble(number);

            Assert.AreEqual(2.0, gama, 0.0216);
        }
Пример #14
0
        public void NotANumberTest()
        {
            var number = double.NaN;

            Assert.IsTrue(double.IsNaN(number));
            var doubleToString = Double754.DoubleToString(number);

            Assert.AreEqual("-1.5000000000000000 * 2^(1024)", doubleToString);
        }
Пример #15
0
        public void LargestDenormalizedNumber()
        {
            var number = BitConverter.Int64BitsToDouble(0x000F_FFFF_FFFF_FFFFL);

            Assert.IsFalse(double.IsNormal(number));
            Assert.AreEqual(2.2250738585072009E-308d, number);
            var doubleToString = Double754.DoubleToString(number);

            Assert.AreEqual("0.9999999999999998 * 2^(-1022)", doubleToString);
        }
Пример #16
0
        public void MiddleDenormalizedNumber()
        {
            var number = BitConverter.Int64BitsToDouble(0x0008_0000_0000_0000L);

            Assert.IsFalse(double.IsNormal(number));
            Assert.AreEqual(1.1125369292536007E-308d, number);
            var doubleToString = Double754.DoubleToString(number);

            Assert.AreEqual("0.5000000000000000 * 2^(-1022)", doubleToString);
        }
Пример #17
0
        public void NegativeZeroTest()
        {
            // 0x8000_0000_0000_0000L
            var number = BitConverter.Int64BitsToDouble(-9_223_372_036_854_775_808L);

            Assert.AreEqual(0.0, number);
            var doubleToString = Double754.DoubleToString(number);

            Assert.AreEqual("0.0000000000000000 * 2^(-1022)", doubleToString);
        }
Пример #18
0
        public void SmallestNormalizedNumber()
        {
            var number = BitConverter.Int64BitsToDouble(0x0010_0000_0000_0000L);

            Assert.IsTrue(double.IsNormal(number));
            Assert.AreEqual(2.2250738585072014E-308d, number);
            var doubleToString = Double754.DoubleToString(number);

            Assert.AreEqual("1.0000000000000000 * 2^(-1022)", doubleToString);
        }
Пример #19
0
        public void ZeroSqrt()
        {
            var number = 0.0;
            var bits   = Double754.DoubleToString(number);

            Assert.AreEqual("0.0000000000000000 * 2^(-1022)", bits);

            var gama = Double754.FastInvSqrtDouble(number);

            Assert.AreEqual(9.6234541417166161E+153, gama);
        }
Пример #20
0
        public void NegativeInfinityTest()
        {
            var number = double.NegativeInfinity;

            Assert.IsTrue(double.IsInfinity(number));
            Assert.IsTrue(double.IsNegativeInfinity(number));
            Assert.AreEqual(double.NegativeInfinity, number);
            var doubleToString = Double754.DoubleToString(number);

            Assert.AreEqual("-1.0000000000000000 * 2^(1024)", doubleToString);
        }
Пример #21
0
        public void LargestNormalizedNumber()
        {
            var number = BitConverter.Int64BitsToDouble(0x7FEF_FFFF_FFFF_FFFFL);

            Assert.IsTrue(double.IsNormal(number));
            Assert.AreEqual(1.7976931348623157E+308d, number);
            Assert.AreEqual(double.MaxValue, number);
            var doubleToString = Double754.DoubleToString(number);

            Assert.AreEqual("1.9999999999999998 * 2^(1023)", doubleToString);
        }
Пример #22
0
        public void ZeroSqrt()
        {
            var number = 0.0;
            var bits   = Double754.DoubleToString(number);

            Assert.AreEqual("0.0000000000000000 * 2^(-1022)", bits);

            var gama = Double754.FastSqrtDouble(number);

            Assert.AreEqual(1.1027156771079482E-154, gama);
        }
Пример #23
0
        public void SmallestDenormalizedNumber()
        {
            var number = BitConverter.Int64BitsToDouble(0x0000_0000_0000_0001L);

            Assert.IsFalse(double.IsNormal(number));
            Assert.AreEqual(4.9406564584124654E-324d, number);
            Assert.AreEqual(double.Epsilon, number);
            var doubleToString = Double754.DoubleToString(number);

            Assert.AreEqual("0.0000000000000002 * 2^(-1022)", doubleToString);
        }
Пример #24
0
        public void Test()
        {
            var number = 256.0;

            Assert.AreEqual("1.0000000000000000 * 2^(8)", Double754.DoubleToString(number));
            var gama = Double754.FastSqrtDouble(number);

            Assert.AreEqual("1.0000000000000000 * 2^(4)", Double754.DoubleToString(16));
            Assert.AreEqual("1.9784999999999968 * 2^(3)", Double754.DoubleToString(gama));
            Assert.AreEqual(16.0, gama, 0.173);
        }
Пример #25
0
        public void Test()
        {
            var number = 256.0;

            Assert.AreEqual("1.0000000000000000 * 2^(8)", Double754.DoubleToString(number));
            var gama = Double754.FastInvSqrtDouble(number);

            Assert.AreEqual("1.0000000000000000 * 2^(-4)", Double754.DoubleToString(0.0625));
            var y = BitConverter.Int64BitsToDouble(0x5FE6F7CED9168800L);

            Assert.AreEqual("1.4355000000000473 * 2^(511)", Double754.DoubleToString(y));

            Assert.AreEqual("1.9355000000000473 * 2^(-5)", Double754.DoubleToString(gama));
            Assert.AreEqual(0.0625, gama, 0.01);
        }
Пример #26
0
        public void VideoFactorFloat()
        {
            var c = 2.3034943820080202E+18d;

            Assert.AreEqual(2_303_494_382_008_020_224L, (long)(c + 0.5));
            Assert.AreEqual(0x1FF7_A7EF_9DB2_2D00L, (long)(c + 0.5));
            var str = Double754.DoubleToString(c);

            Assert.AreEqual("1.9979628906250000 * 2^(60)", str);

            var mu   = 0.0430;
            var c1   = 1.0 / 2.0;
            var c2   = Math.Pow(2.0, 52);
            var c3   = 1023.0 - mu;
            var calc = c1 * c2 * c3;

            Assert.AreEqual(c, calc);
        }
Пример #27
0
        public void VideoFactorDouble()
        {
            var c = 6.9104831460240609E+18;

            Assert.AreEqual(6910483146024060928L, (long)(c + 0.5));
            Assert.AreEqual(0x5FE6F7CED9168800L, (long)(c + 0.5));
            Assert.AreEqual(6.9104831460240609E+18, c);
            var str = Double754.DoubleToString(c);

            Assert.AreEqual("1.4984721679687500 * 2^(62)", str);

            var mu   = 0.0430;
            var c1   = 3.0 / 2.0;
            var c2   = Math.Pow(2.0, 52);
            var c3   = 1023.0 - mu;
            var calc = c1 * c2 * c3;

            Assert.AreEqual(c, calc);
        }