Here you can find the source of roundUp(int number, int interval)
public static int roundUp(int number, int interval)
//package com.java2s; //License from project: LGPL public class Main { /**//from w w w. ja v a 2 s. c om * Rounds the first parameter up to the next interval of the second parameter. * * For instance, {@code roundUp(1, 4)} returns 4; {@code roundUp(0, 4)} returns 0; and {@code roundUp(4, 4)} returns * 4. */ public static int roundUp(int number, int interval) { if (interval == 0) { return 0; } else if (number == 0) { return interval; } else { if (number < 0) { interval *= -1; } int i = number % interval; return i == 0 ? number : number + interval - i; } } }