Math.Ceiling();向上取整
Math.Ceiling()向上取整; d = 4.56789 string res = Math.Ceiling(Convert.ToDecimal(d)).ToString(); res=5
Math.Floor()向下取整 ;string res = Math.Floor(Convert.ToDouble(d)).ToString(); es=4
Math.Round是"就近舍入",当要舍入的是5时与"四舍五入"不同(取偶数),如:
Math.Round(0.5,0)=0
floor 和 ceiling是math unit 里的函数,使用前要先 Uses Math。
trunc 和 round 是system unit 里的函数,缺省就可以用。
floor 直接往小的取,比如 floor(-123.55)=-124,floor(123.55)=123
trunc 直接切下整数,比如 trunc(-123.55)=-123, floor(123.55)=123
ceil 直接往大的取,比如 ceil(-123.55)=-123, ceil(123.55)=124
round 计算四舍五入,比如 round(-123.55)=-124,round(123.55)=124
c# 取整
原创
©著作权归作者所有:来自51CTO博客作者xiaobinzeng的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:基础地图Android SDK
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Mysql上取整 mysql除法取整
mysql数据库数字取整,截取部分字段,日期
Mysql上取整 mysql 四舍五入 字段