c# hexadecimal to floating point number single precision type:

c# hexadecimal to floating point number single precision type:

string s = "4144147B";
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, System.Globalization.NumberStyles.AllowHexSpecifier);
float m = BitConverter.ToSingle(bytes.Reverse().ToArray(), 0);
Console.WriteLine(m);

Guess you like

Origin blog.csdn.net/BeanGo/article/details/129377327