Saturday, August 30, 2014

How to round to the nearest whole number in C# ?

I have Googled for it and found some interesting answers:

My problem was solved by simple using on Math.Ceiling

var wholeNumber = (int)Math.Ceiling(fractionalNumber);

And other interesting answers are :

Math.Ceiling
always rounds up (towards the ceiling)
Math.Floor
always rounds down (towards to floor)


References :

No comments: