I want to round up double to int.
Eg,
double a=0.4, b=0.5;
I want to change them both to integer.
so that
int aa=0, bb=1;
aa
is from a
and bb
is from b
.
Any formula to do that?
See Question&Answers more detail:osI want to round up double to int.
Eg,
double a=0.4, b=0.5;
I want to change them both to integer.
so that
int aa=0, bb=1;
aa
is from a
and bb
is from b
.
Any formula to do that?
See Question&Answers more detail:osUse Math.Ceiling
to round up
Math.Ceiling(0.5); // 1
Use Math.Round
to just round
Math.Round(0.5, MidpointRounding.AwayFromZero); // 1
And Math.Floor
to round down
Math.Floor(0.5); // 0