Java Utililty Methods floor

List of utility methods to do floor

Description

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

Method

intfloorDiv(int dividend, int divisor)
Computes the floored division dividend/divisor which is useful when dividing potentially negative numbers into bins.
return ((dividend >= 0) ? dividend : (dividend - divisor + 1)) / divisor;
intfloorDiv(int v1, int v2)
floor Div
return v1 / v2 - (((v1 % v2 != 0) && negativeProduct(v1, v2)) ? 1 : 0);
longfloorDiv(long a, long b)
Returns the floor division.
return (a >= 0 ? a / b : ((a + 1) / b) - 1);
longfloorDiv(long x, long y)
Divide, rounding towards negative infinity.
long r = x / y;
if ((x ^ y) < 0 && (r * y != x)) {
    r--;
return r;
intfloorDivide(int value, int divisor)

Returns the largest lower limit of quotient.

{@code floorDivide(1, 2) == 0}</li>
     *  <li>{@code floorDivide(0, 2) == 0}</li>
     *  <li>{@code floorDivide(-1, 2) == -1}</li>
     *  <li>{@code floorDivide(-2, 2) == -1}</li>
     *  <li>{@code floorDivide(-3, 2) == -2}</li>
     * </ul>
     *
     * @param   value       numerator
     * @param   divisor     divisor
        ...
longfloorDivide(long n, long d)
floor Divide
return ((n >= 0) ? (n / d) : (((n + 1L) / d) - 1L));
longfloorDivide(long numerator, long denominator)
Divide two long integers, returning the floor of the quotient.
return (numerator >= 0) ? (numerator / denominator) : (((numerator + 1) / denominator) - 1);
intfloorDivision(int i, int divisor)
floor Division
return floor(((float) i) / divisor);
intfloorHalf(int num)
Returns the floor of the half of the input value
if ((num & 1) == 1) {
    return (num - 1) / 2;
} else {
    return num / 2;
DoublefloorInt(Double d, double intv)
floor Int
if (d < 0) {
    d -= intv * 0.9999999;
d = d / intv;
d = d < 0 ? Math.ceil(d - 0.0000000000001) : Math.floor(d + 0.0000000000001);
return d * intv;