代码之家  ›  专栏  ›  技术社区  ›  TheBoubou codingbadger

用C四舍五入到上面的单位#

  •  1
  • TheBoubou codingbadger  · 技术社区  · 14 年前

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

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

    (int)math.round(count/(decimal)行,中点rounding.awayfromzero)

    2 回复  |  直到 13 年前
        1
  •  12
  •   spender    14 年前

    Math.Ceiling 是你的朋友

        2
  •  0
  •   Community c0D3l0g1c    7 年前

    Eric Lippert's answer 放得很好。