C#中取整,向上取,向下取
2021-02-20 11:20
标签:取整 tostring log 向上取整 ceiling 示例 div string class C#中取整,向上取,向下取 标签:取整 tostring log 向上取整 ceiling 示例 div string class 原文地址:https://www.cnblogs.com/ShaYeBlog/p/8287574.htmlMath.Ceiling()向上取整,Math.Floor()向下取整
示例:
d = 4.56789
string res = Math.Ceiling(Convert.ToDecimal(d)).ToString()
或string res = Math.Ceiling(Convert.ToDouble(d)).ToString();
res为5 string res = Math.Floor(Convert.ToDecimal(d)).ToString()
或string res = Math.Floor(Convert.ToDouble(d)).ToString(); res为4
上一篇:C#中decimal ,double,float的区别
下一篇:C#图片验证码绘制