C# double addition - strange behaviour

后端 未结 2 1023
慢半拍i
慢半拍i 2020-12-20 02:57
public static void Main()
{
    Dictionary values = new Dictionary();
    values.Add(\"a\", 0.002);
    values.Add(\"b\",         


        
2条回答
  •  醉梦人生
    2020-12-20 03:25

    The problem with double/float's is that they are binary numbers, aka 1000110.10101001 internally, and therefore only represent an approximate representation of your values.

    Read Jon Skeet's explanation: Difference between decimal, float and double in .NET?

提交回复
热议问题