C#怎样把浮点数的十六进制化成十进制数
例如我有十六进制数:47 7A 45 C2,十进制数是:-49.3694 ;如何用C# 把他化成十进制数?求具体代码
[解决办法]
这样就行了:
string s = "477A45C2";
MatchCollection matches = Regex.Matches(s, @"[0-9A-Fa-f]{2}");
byte[] bytes = new byte[matches.Count];
for (int i = 0; i < bytes.Length; i++)
bytes[i] = byte.Parse(matches[i].Value, NumberStyles.AllowHexSpecifier);
float m = BitConverter.ToSingle(bytes, 0);
Response.Write(m);