C# 小数点后保留两位小数,四舍五入的函数及使用方法

Math.Round(45.367,2)     //Returns   45.37

Math.Round(45.365,2)     //Returns   45.36

 

说明:

 C#中的Round()不是我们中国人理解的四舍五入,是老外的四舍五入,是符合IEEE标准的四舍五入,具体是五舍六入。

 

下面的才是符合中国人理解的四舍五入

Math.Round(45.367,2,MidpointRounding.AwayFromZero);    //Returns   45.37   

Math.Round(45.365,2,MidpointRounding.AwayFromZero)     //Returns   45.37   

posted on 2014-08-13 09:50  无情的雨  阅读(222)  评论(1编辑  收藏  举报

导航