Here you can find the source of roundUp(int n, int nearestMultiple)
Parameter | Description |
---|---|
n | the value to round up |
nearestMultiple | the nearest multiple to round to |
public static int roundUp(int n, int nearestMultiple)
//package com.java2s; //License from project: Open Source License public class Main { /**//from ww w .j a va 2 s . com * Round up the given value to given nearest multiple. * * @param n the value to round up * @param nearestMultiple the nearest multiple to round to * @return the rounded value */ public static int roundUp(int n, int nearestMultiple) { return n + nearestMultiple - 1 - (n - 1) % nearestMultiple; } }