// 16进制字符串,转化为浮点数
public float HexToFloat(String hexString)
{
uint num = uint.Parse(hexString, System.Globalization.NumberStyles.AllowHexSpecifier);
byte[] floatVals = BitConverter.GetBytes(num);
return BitConverter.ToSingle(floatVals, 0);
}
// 测试用例
private void button9_Click(object sender, EventArgs e)
{
MessageBox.Show(HexToFloat("43480170").ToString());
}
public float HexToFloat(String hexString)
{
uint num = uint.Parse(hexString, System.Globalization.NumberStyles.AllowHexSpecifier);
byte[] floatVals = BitConverter.GetBytes(num);
return BitConverter.ToSingle(floatVals, 0);
}
// 测试用例
private void button9_Click(object sender, EventArgs e)
{
MessageBox.Show(HexToFloat("43480170").ToString());
}
modbus tcp
天星直播:http://www.jkav.tk/