Example #1
0
        public void Test_ToDouble()
        {
            var    converter = new DefaultConverter();
            double theDouble = 2.3d;

            var          bytes    = BitConverter.GetBytes(theDouble);
            var          actual   = converter.ToDouble(bytes, 0, false);
            const double expected = 2.3d;

            Assert.AreEqual(expected, actual);
        }
Example #2
0
        public void Test_ToDouble_UseNbo()
        {
            var    converter = new DefaultConverter();
            double theDouble = 2.3d;

            var          bytes    = BitConverter.GetBytes(theDouble).Reverse().ToArray();
            var          actual   = converter.ToDouble(bytes, 0, true);
            const double expected = 2.3d;

            Assert.AreEqual(expected, actual);
        }
Example #3
0
        public void Test_ToDouble(double value, bool useNbo)
        {
            var converter = new DefaultConverter();

            var bytes = BitConverter.GetBytes(value);

            if (useNbo)
            {
                bytes = bytes.Reverse().ToArray();
            }

            var actual = converter.ToDouble(bytes.AsSpan(), useNbo);

            Assert.Equal(value, actual);
        }