2010-08-30

Floating Point / Single to Hexadecimal (IEEE 754)

public string FloatToHex(float valueToConvert)
{
   byte[] byteArray = BitConverter.GetBytes(valueToConvert);
   Array.Reverse(byteArray);
 
   return BitConverter.ToString(byteArray).Replace("-""");
}

Output example: 12345.6 -> 4640E666

Solution came from VB.NET Hexadecimal to Floating Point / Single (IEEE 754)
What is IEEE 754 Floating-Point Arithmetic Standard?
Post a Comment