Java Number Round roundUp(int n, int nearestMultiple)

Here you can find the source of roundUp(int n, int nearestMultiple)

Description

Round up the given value to given nearest multiple.

License

Open Source License

Parameter

Parameter Description
n the value to round up
nearestMultiple the nearest multiple to round to

Return

the rounded value

Declaration

public static int roundUp(int n, int nearestMultiple) 

Method Source Code

//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;
    }
}

Related

  1. roundUp(int capacity)
  2. roundUp(int dividend, int divisor)
  3. roundUp(int groupSize, int globalSize)
  4. roundUp(int groupSize, int globalSize)
  5. roundUp(int i, int snap)
  6. roundUp(int ndigits)
  7. roundUp(int num, int divisor)
  8. roundUp(int number, int interval)
  9. roundUp(int p_154354_0_, int p_154354_1_)