标签:turn [] bsp converter nbsp color code val oat
C# IEE754算法,仪表设备经常用的数据指令.16进制转10进制,10进制转16进制互转.留作备份,并发给刚入门工控的人.
算法原理很多人都解释啦,在此就不多说啦,时间有限,上来就干!
public static class IEE754Method { public static float HexToFloat(this string hexValue) { try { uint uintValue = Convert.ToUInt32(hexValue, 16); byte[] bytesValue = BitConverter.GetBytes(uintValue); float floatValue = BitConverter.ToSingle(bytesValue, 0); return floatValue; } catch { throw; } } public static string FloatToHex(this float floatValue) { try { byte[] bytesValue = BitConverter.GetBytes(floatValue); int intValue = BitConverter.ToInt32(bytesValue, 0); return intValue.ToString("X8"); } catch { throw; } } }
标签:turn [] bsp converter nbsp color code val oat
原文地址:https://www.cnblogs.com/mr-meng/p/IEE754.html