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.
aa
a
bb
b
Any formula to do that?
Use Math.Ceiling to round up
Math.Ceiling
Math.Ceiling(0.5); // 1
Use Math.Round to just round
Math.Round
Math.Round(0.5, MidpointRounding.AwayFromZero); // 1
And Math.Floor to round down
Math.Floor
Math.Floor(0.5); // 0
2.1m questions
2.1m answers
60 comments
57.0k users