c#中十六进制字符串转单精度浮点数

1 var countBytes = new byte[] { 66, 12, 25, 217 };
2 var countHexStr = ToHexStrFromByte(countBytes.ToArray());                                  
3 uint num = uint.Parse(countHexStr, System.Globalization.NumberStyles.AllowHexSpecifier);
4 byte[] floatVals = BitConverter.GetBytes(num);
5 float floatResult = BitConverter.ToSingle(floatVals, 0);
6 result = floatResult.ToString();

 

 

posted @ 2023-06-08 11:49  tommy~hi  阅读(874)  评论(1编辑  收藏  举报