Round Up a double to int

后端 未结 4 2091
执笔经年
执笔经年 2020-12-20 11:01

I have a number (\"double\") from int/int (such as 10/3).

What\'s the best way to Approximation by Excess and convert it to int on C#?

4条回答
  •  没有蜡笔的小新
    2020-12-20 11:33

    Are you asking about System.Math.Ceiling?

    Math.Ceiling(0.2) == 1
    Math.Ceiling(0.8) == 1
    Math.Ceiling(2.6) == 3
    Math.Ceiling(-1.4) == -1
    

提交回复
热议问题