Java Utililty Methods Double Number Round

List of utility methods to do Double Number Round

Description

The list of methods to do Double Number Round are organized into topic(s).

Method

longRoundDown(final T number)
Returns a long number by round down with specify number.
Returns 0 if number == null.
e.g: average is 3.5, then return 3.
if (number == null) {
    return 0;
return number.longValue();
introundDown(int n, int m)
round Down
while (n % m != 0)
    n--;
return n;
introundDown(int number, int mod)
round Down
return number / mod * mod;
introundDown(int val, int shift)
Rounds an integer down to the nearest multiple of 2^shift .
return val >>> shift << shift;
introundDown(int val, int to)
Round the value down to the closest value of to.
int temp = val % to;
if (temp < 3) {
    return val - temp;
} else {
    return val + to - temp;
introundDown(long n, long m)
Round n down to nearest multiple of m.
return (int) ((n / m) * m);
longroundDown(long size, long roundBoundary)
round Down
return (size - (size % roundBoundary));
longroundDown(long val, long delta)
round Down
boolean isNegative = val < 0;
val = Math.abs(val);
val = val / delta * delta;
return !isNegative ? val : -val;
introundDownTo(int a, int quanta)
round Down To
return a & -quanta;
doubleroundDownToNearest(double number, double nearest)
round Down To Nearest
return Math.floor(roundToPrecision(number / nearest, 10)) * nearest;