Java Integer Mod mod(int a, int n)

Here you can find the source of mod(int a, int n)

Description

return the modulus in the range [0, n)

License

GNU General Public License

Declaration

public static int mod(int a, int n) 

Method Source Code

//package com.java2s;
// License: GPL. For details, see LICENSE file.

public class Main {
    /**//from  w ww  .ja v a  2  s  .co m
     * return the modulus in the range [0, n)
     */
    public static int mod(int a, int n) {
        if (n <= 0)
            throw new IllegalArgumentException();
        int res = a % n;
        if (res < 0) {
            res += n;
        }
        return res;
    }
}

Related

  1. mod(final int n, final int N)
  2. mod(int a, int b)
  3. Mod(int a, int b)
  4. mod(int a, int b)
  5. mod(int a, int b)
  6. mod(int a, int n)
  7. mod(int divisor, int dividend)
  8. mod(int hash, int size)
  9. mod(int i, int n)