this question has answer here:
- how convert 3 bytes 24 bit number in c#? 5 answers
i bytes speed sensor:
byte[] array = new byte[2]; array[0] = response.getdatapayload()[6]; array[1] = response.getdatapayload()[7];
first msb (most significant byte) , second 1 lsb (less significant byte). know because that's sais in documentation...
how can transform 2 variables int/double? (in c#)
there built-in class called bitconverter that:
byte[] array = new byte[2]; array[0] = response.getdatapayload()[7]; array[1] = response.getdatapayload()[6]; //or, do: array[0] = response.getdatapayload()[6]; array[1] = response.getdatapayload()[7]; array.reverse(array); //end-or short myvar = bitconverter.toint16(array, 0); int myint = (int)myvar; double mydouble = (double)myvar;
since 2 bytes short (16 bit integer) thats out of sensor. can cast full 32-bit integer or double if want.
the bytes swapped endianness.