C# - Rounding Down to Nearest Integer
Solution 1:
Just try this..
int interval = Convert.ToInt32(Math.Floor(different/increment));
Solution 2:
Use the static Math
class:
int interval = (int)Math.Floor(difference/increment);
Math.Floor()
will round down to the nearest integer.
Solution 3:
You can also just simply cast the result to int
. This will truncate the number.
int interval = (int)(difference / increment);
Solution 4:
The Math.Floor()
function should do the trick:
int interval = (int)Math.Floor(difference / increment);
See also: https://msdn.microsoft.com/de-de/library/e0b5f0xb%28v=vs.110%29.aspx
Solution 5:
Convert.ToSingle();
is another method