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

时间:2014-08-13 10:22:35   收藏:0   阅读:368
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   

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

原文:http://www.cnblogs.com/mowuyan/p/3909266.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!