Categories
Coding

Rounding to nearest X

An interesting forumla to remember for rounding numbers to the nearest X. Int32 value = 43.7; Int32 toNearest = 5; Int32 result = Math.Round(value / toNearest) * toNearest;

An interesting forumla to remember for rounding numbers to the nearest X.

Int32 value = 43.7;
Int32 toNearest = 5;
Int32 result = Math.Round(value / toNearest) * toNearest;