c# - 使用 C# 舍入到上面的单位

标签 c# rounding

如何将小数向上舍入到最接近的整数。

1.2 ---> 2
5.6 ---> 6
79.9 ---> 80
85.01 ---> 86

(int)Math.Round(count/(decimal)rows, MidpointRounding.AwayFromZero)

最佳答案

Math.Ceiling 是你的 friend

关于c# - 使用 C# 舍入到上面的单位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2274885/

相关文章:

numbers - 扩大数字

c# - 在 .Net 中创建和验证 x509 证书

c# - ^[A-Za-Z ][A-Za-z0-9 ]* 正则表达式?

c# - 如果未找到任何内容,如何为 LINQ 返回特定值?

c# - 如何将 'Convert' 类包装到通用函数中

c# - 我想要什么 WinForm 控件?

javascript - 为什么 Math.floor() 优于 Math.round()? [JavaScript]

java - 在四舍五入的小数位周围添加括号

python - 将 float 四舍五入到最接近的整数?

Fortran - 想要四舍五入到小数点后一位