Math.Round返回错误的结果

时间:2018-08-24 12:19:44

标签: c#

在下面的简单代码中,给我Math.Round不同的结果。我错过了什么吗?

public static void Main()
        {
                 double amt = 511.555;
                 double round = Math.Round(amt, 2, MidpointRounding.AwayFromZero);
                 Console.WriteLine(round); 
                 //Returns 511.56
                 amt = 512.555;
                 round = Math.Round(amt, 2, MidpointRounding.AwayFromZero);
                 Console.WriteLine(round); 
                //Returns 512.55
               Console.ReadKey();
        }

0 个答案:

没有答案