List of utility methods to do Integer Mod
int | mod(final int dividend, final int divisor) Java's modulus operator is disappointingly different to other languages. assert divisor > 0 : "have not implemented negative divisors yet"; int dividend2 = dividend; if (dividend2 < 0) { int makePositive = (1 + -1 * dividend2 / divisor) * divisor; dividend2 = dividend2 + makePositive; return dividend2 % divisor; |
int | mod(final int dividend, final int divisor) mod return dividend % divisor;
|
int | mod(final int n, final int N) mod final double co; co = (n - N * (n / N)); return ((int) co); |
int | mod(int a, int b) mod return a % b;
|
int | Mod(int a, int b) The result of the "modulus" operator (a mod b) is defined as the remainder of the integer division (a / b). if (b == 0) return a; if (a * b >= 0) return a - b * (a / b); else return a - b * (a / b - 1); |
int | mod(int a, int b) Utility which does *proper* modding, where the result is guaranteed to be positive. return ((a % b) + b) % b;
|
int | mod(int a, int b) Computes the mathematical modulus of two numbers. return ((a % b) + b) % b;
|
int | mod(int a, int n) "correct" mod function. if (n < 0) return mod(a, -n); if (n == 0) return a % n; int rtn = a % n; while (rtn < 0) rtn += n; return rtn; ... |
int | mod(int a, int n) return the modulus in the range [0, n) if (n <= 0) throw new IllegalArgumentException(); int res = a % n; if (res < 0) { res += n; return res; |
int | mod(int divisor, int dividend) mod return (((divisor % dividend) + dividend) % dividend);
|