Java Integer Mod modCeil(int x, int mod)

Here you can find the source of modCeil(int x, int mod)

Description

Rounds x up to a lowest number that is greater or equal to x and is divisible by mod.

License

Apache License

Parameter

Parameter Description
x the number to round, must be >= 0
mod the modulo, must be >= 1

Return

the rounded value

Declaration

public static int modCeil(int x, int mod) 

Method Source Code

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

Related

  1. mod(int[]... vectors)
  2. mod(long l, int m)
  3. mod4(int a)
  4. mod_diff(int x, int y, int R)
  5. modByPowerOfTwo(int value, int mod)
  6. mode(final StringBuilder buffer, final int mode)
  7. ModEuclidean(int D, int d)
  8. modifyAlpha(int color, int alpha)
  9. modifyBase32AtIndex(final String s, final int index)