Java Utililty Methods Integer Divide

List of utility methods to do Integer Divide

Description

The list of methods to do Integer Divide are organized into topic(s).

Method

intdivideWithoutOverflow(int x, int y)
Integer divide without overflow
if (x == Integer.MIN_VALUE && y == -1) {
    throw new ArithmeticException("integer overflow");
return x / y;
doubledivision(int i_Divisor, int i_Dividend)
division
if (i_Dividend != 0) {
    return ((double) i_Divisor) / ((double) i_Dividend);
} else {
    return 0;
intdivisor(int a, int b)
divisor
return (a < 0) ? ((a % b) + b) % b : a % b;
intdivisor(int m, int n)
divisor
if (m % n == 0) {
    return n;
} else {
    return divisor(n, m % n);
intdivisorMod(int a, int n)
Modulus, divisor-style.
return (int) (a - n * Math.floor(Math.floor(a) / n));
intdivRoundUp(int a, int b)
div Round Up
if (b > a) {
    return 1;
int result = a % b;
return result == 0 ? a / b : (a - result) / b + 1;
intdivUp(int dividend, int divisor)
divides integers with rounding up
return (dividend + divisor - 1) / divisor;