将字节转换为浮点值 [英] Convert bytes to float values
本文介绍了将字节转换为浮点值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要将28个字节的值转换为7个浮点值,每个4个字节表示1个浮点值。我必须在C#中实现这一点。我搜索了很多解决方案,但大多数解决方案都在C / Java中。
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.
推荐答案
使用
System.BitConverter.ToSingle(..)
就像这样:
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);
这篇关于将字节转换为浮点值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文