【发布时间】:2017-01-05 02:28:47
【问题描述】:
我声明了一个包含 4 个字节的字节数组。
byte[] bts = new byte[] { 0xff, 0xff, 0x7f, 0x7f };
float f1 = BitConverter.ToSingle(bts, 0);
string s = f1.ToString();
float f2 = float.Parse(s);
byte[] bts2 = BitConverter.GetBytes(f2);
经过一些转换,我意识到输出从
{ 0xff, 0xff, 0x7f, 0x7f }
到
{ 0xfD, 0xff, 0x7f, 0x7f }
为什么会这样?
【问题讨论】:
-
欢迎来到 StackOverflow!请澄清您的具体问题或添加其他详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。请参阅How to Ask 页面以获得澄清此问题的帮助。
标签: c# .net floating-point formatting tostring