Beispiel #1
0
        public static float ReadFloat(byte[] msg, int index)
        {
            FloatConverter fc = new FloatConverter();

            fc.Byte0 = msg[index];
            fc.Byte1 = msg[index + 1];
            fc.Byte2 = msg[index + 2];
            fc.Byte3 = msg[index + 3];
            return(fc.FloatValue);
        }
Beispiel #2
0
        public static void WriteFloat(byte[] msg, float val, int index)
        {
            // TODO: does this need to account for endianness?
            FloatConverter fc = new FloatConverter();

            fc.FloatValue  = val;
            msg[index]     = fc.Byte0;
            msg[index + 1] = fc.Byte1;
            msg[index + 2] = fc.Byte2;
            msg[index + 3] = fc.Byte3;
        }