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

doubleroundDoubleToPlace(double d, int place)
round Double To Place
if (place < 0)
    throw new IllegalArgumentException();
if (place > 9)
    throw new IllegalArgumentException();
long factor = (long) Math.pow(10, place);
return ((double) Math.round(d * factor)) / factor;
doubleroundDoubleValue(double value)
Rounds a double value to the first two digits.
double roundedValue = Math.round(value * 100) / 100.0;
return roundedValue;
introundDown(double a)
Returns the closest int to the argument, with ties rounding down.
double r = a % 1;
if (r < 0)
    r += 1;
return r == 0.5 ? (int) Math.round(a) - 1 : (int) Math.round(a);
doubleroundDown(double amt, double digits)
round Down
double powValue = Math.pow(10, digits);
amt = amt * powValue;
amt = ((int) amt);
amt = amt / powValue;
return amt;
introundDown(double n)
Round the given number to the nearest whole that is smaller than the number.
return (int) n;
doubleroundDown(double num)
round Down
return Double.valueOf(String.format("%.2f", num));
doubleroundDown(double val, int decimals)
Cut a value to given number of decimals.
double pow = Math.pow(10, decimals);
return Math.floor(val * pow) / pow;
doubleroundDown(double value, double units)
round Down
double scaled = value / units;
return Math.floor(scaled) * units;
introundDown(double value, int gridSize)
round Down
return (int) (Math.floor(value / gridSize) * gridSize);
introundDown(final float realNumber)
Round the number down to the closest integer
return (int) Math.round(Math.floor(realNumber));