Exemple #1
0
        public void t1()
        {
            // 一次累计流量 1027
            //
            byte[] bs = new byte[]{0x03, 0x04, 0x00, 0x00};
            Int32Converter c = new Int32Converter();
            int i = (int)c.ConvertToObject(bs);

            FloatConverter f = new FloatConverter();
            float fv = (float)f.ConvertToObject(bs);
            fv = (float)Math.Round(fv, 2);

            //Assert.AreEqual(i, fv);

            f.IsLittleEndian = false;
            bs = f.ConvertToBytes(10.01F);
            float f2 = (float)f.ConvertToObject(bs);
            Assert.AreEqual(10.01F, f2);
        }
Exemple #2
0
        public void t1()
        {
            // 一次累计流量 1027
            //
            byte[]         bs = new byte[] { 0x03, 0x04, 0x00, 0x00 };
            Int32Converter c  = new Int32Converter();
            int            i  = (int)c.ConvertToObject(bs);

            FloatConverter f  = new FloatConverter();
            float          fv = (float)f.ConvertToObject(bs);

            fv = (float)Math.Round(fv, 2);

            //Assert.AreEqual(i, fv);


            f.IsLittleEndian = false;
            bs = f.ConvertToBytes(10.01F);
            float f2 = (float)f.ConvertToObject(bs);

            Assert.AreEqual(10.01F, f2);
        }