Here you can find the source of modCeil(int x, int mod)
x
up to a lowest number that is greater or equal to x
and is divisible by mod
.
Parameter | Description |
---|---|
x | the number to round, must be >= 0 |
mod | the modulo, must be >= 1 |
public static int modCeil(int x, int mod)
//package com.java2s; //License from project: Apache License public class Main { /**/*ww w . ja va 2 s . co m*/ * Rounds <code>x</code> up to a lowest number that is greater or equal to * <code>x</code> and is divisible by <code>mod</code>. * * @param x * the number to round, must be >= 0 * @param mod * the modulo, must be >= 1 * * @return the rounded value */ public static int modCeil(int x, int mod) { return x + (mod - x % mod) % mod; } }