博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
c#中 字节数组到浮点型转换
阅读量:7076 次
发布时间:2019-06-28

本文共 429 字,大约阅读时间需要 1 分钟。

第一种方法:     byte j1 = ReceiveBytes[4]; //还原第1字节(低位)                    int j2 = ReceiveBytes[5] * 256; //还原第2字节   << 8                    int j3 = j1 + j2;//得到整型                    float j4 = j3 / 1000;

串口通信中用到的     http://www.cnblogs.com/binfire/archive/2011/10/08/2201973.html   讲了串口通信操作

 

第二种方法:

float S_acc_x = (float)((Int16)(ReceiveBytes[j] << 8 | ReceiveBytes[j + 1])) / 100;//字节处理

 

转载于:https://www.cnblogs.com/rechen/p/5089066.html

你可能感兴趣的文章