如何在C#字符串“-0”中解析为双-0.0?

时间:2018-05-08 12:49:58

标签: c# double

如何解析C#string “ - 0”到长值 -9223372036854775808 (十六进制: 0x8000000000000000 )?< / p>

以下代码显示值不相等。

double negativeZero = -0.0;
long negativeZeroLong = BitConverter.DoubleToInt64Bits(negativeZero);  // 0x8000000000000000
long parsedNegativeZeroLong = BitConverter.DoubleToInt64Bits(System.Double.Parse("-0.0", System.Globalization.NumberStyles.Float)); //0
Console.WriteLine("{0} != {1}", negativeZeroLong.ToString("X"), parsedNegativeZeroLong.ToString("X")); //8000000000000000 != 0

0 个答案:

没有答案