问题
I need to convert 28 byte value to a 7 float values, each 4 bytes denote 1 float value. I have to implement this in C#. I searched for lot of solutions, but most of them were in C/Java.
回答1:
Use
System.BitConverter.ToSingle(..)
Like this:
float f1,f2,f3,f4,f5,f6,f7;
f1 = System.BitConverter.ToSingle(bytearr,0);
f2 = System.BitConverter.ToSingle(bytearr,4);
f3 = System.BitConverter.ToSingle(bytearr,8);
...
f7 = System.BitConverter.ToSingle(bytearr,24);
回答2:
Like so:
byte b;
float f;
f = (float)b;
来源:https://stackoverflow.com/questions/11773520/convert-bytes-to-float-values