然後他輸出是16進位,要轉成浮點數。
這邊的簡單算試需要自己去確認是 Big Endian 還是 Little Endian
傳 412C5757進去計算會得出 浮點數
vb.net
Function Dec3(n As String)
Dim num As UInt32 = UInt32.Parse(n, System.Globalization.NumberStyles.AllowHexSpecifier)
Dim floatVals As Byte() = BitConverter.GetBytes(num)
Dim f As Single = BitConverter.ToSingle(floatVals, 0)
Return f
End Function
C#
String hexString = "43480170";
uint num = uint.Parse(hexString, System.Globalization.NumberStyles.AllowHexSpecifier);
Byte[] floatVals = BitConverter.GetBytes(num);
float f = BitConverter.ToSingle(floatVals, 0);
Console.WriteLine("float convert = {0}", f);
0 意見:
張貼留言