markzzz markzzz - 2 months ago 21
C# Question

Round Up a double to int

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

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