阅读背景:

为什么在变量中存储值会改变相等比较的结果?

来源:互联网 

Output of the following code:

输出以下代码:

var a = 0.1;
var count = 1;

while (a > 0)
{
    if (count == 323)
    {
        var isZeroA = (a * 0.1) == 0;
        var b = a * 0.1;
        var isZeroB = b == 0;

        Console.WriteLine("IsZeroA: {0}, IsZeroB: {1}", isZeroA, isZeroB);
    }

    a *= 0.1;
    ++count;
}
var a



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: