Round Up a double to int

markzzz picture markzzz · Feb 15, 2012 · Viewed 51k times · Source

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#?

Answer

Doug McClean picture Doug McClean · Feb 15, 2012

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