Rounding up a number to nearest multiple of 5

To round to the nearest of any value

int round(double i, int v){
    return Math.round(i/v) * v;
}

You can also replace Math.round() with either Math.floor() or Math.ceil() to make it always round down or always round up.

Leave a Comment