I need to round a double to nearest five. I can't find a way to do it with the Math.Round function. How can I do this?
What I want:
70 = 70 73.5 = 75 72 = 70 75.9 = 75 69 = 70
and so on..
Is there an easy way to do this?
Use your number line, number from 1-10 and jump from 9 back to 5 and from 9 forward to 10. They can see that you have to jump 4 times to get to 5 but only once to get to 10. 9 rounded of to the nearest 5 is then equal to 10.
To round to the nearest 5 in Excel, you can use the MROUND function.
Try:
Math.Round(value / 5.0) * 5;
This works:
5* (int)Math.Round(p / 5.0)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With