public static double ReadDouble(byte[] msg, int index) { DoubleConverter dc = new DoubleConverter(); dc.Byte0 = msg[index]; dc.Byte1 = msg[index + 1]; dc.Byte2 = msg[index + 2]; dc.Byte3 = msg[index + 3]; dc.Byte4 = msg[index + 4]; dc.Byte5 = msg[index + 5]; dc.Byte6 = msg[index + 6]; dc.Byte7 = msg[index + 7]; return(dc.DoubleValue); }
public static void WriteDouble(byte[] msg, double val, int index) { // TODO: does this need to account for endianness? DoubleConverter dc = new DoubleConverter(); dc.DoubleValue = val; msg[index] = dc.Byte0; msg[index + 1] = dc.Byte1; msg[index + 2] = dc.Byte2; msg[index + 3] = dc.Byte3; msg[index + 4] = dc.Byte4; msg[index + 5] = dc.Byte5; msg[index + 6] = dc.Byte6; msg[index + 7] = dc.Byte7; }