I have a float
number of 1.000001f
I want to round it up to the next integer. In this case to 2
.
How can I do that?
I tried Math.Floor
, Math.Ceiling
, Math.Round
. Nothing works.
I have a float
number of 1.000001f
I want to round it up to the next integer. In this case to 2
.
How can I do that?
I tried Math.Floor
, Math.Ceiling
, Math.Round
. Nothing works.
Shouldn't have an issue with this using Math.Ceiling
float precise = 1.000001f;
var roundedUp = (int)Math.Ceiling(precise); // 2: System.Int32
note - roundedUp
will be of type System.Double
without the (int)
cast
.NET Fiddle - demo