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

doubleroundDouble(double number, int precision)
Returns the rounded double number with a given precision.
int temp = (int) ((number * Math.pow(10, precision)));
return (((double) temp) / Math.pow(10, precision));
doubleroundDouble(double pDouble, int pPlaces)
round Double
return Math.round(pDouble * Math.pow(10, (double) pPlaces)) / Math.pow(10, (double) pPlaces);
DoubleroundDouble(double val, int precision)
roundDouble.
double factor = Math.pow(10, precision);
return Math.floor(val * factor + 0.5) / factor;
doubleroundDouble(double value)
This method takes double value as a parameter and rounds it to two decimal points and returns the rounded value.
int decimalPlace = 2;
double power_of_ten = 1;
while (decimalPlace-- > 0) {
    power_of_ten *= 10.0;
return Math.round(value * power_of_ten) / power_of_ten;
doubleroundDouble(double value, int afterDecimalPoint)
Rounds a double to the given number of decimal places.
double mask = Math.pow(10.0, (double) afterDecimalPoint);
return (double) (Math.round(value * mask)) / mask;
doubleroundDouble3(double r)
round Double
return roundDouble(r, 3);
doubleroundDoubleDownTo(double value, double steps)
round Double Down To
if (steps == 0) {
    return value;
} else {
    return Math.floor(value / steps) * steps;
doubleroundDoubleNicely(double intensity)
round Double Nicely
return Math.round(intensity * 10000f) / 10000f;
doubleroundDoubleTo(double val, int pow)
Function to round off a double value upto a specific decimal place.
double p = (double) Math.pow(10, pow);
val = val * p;
double tmp = (double) (Math.round(val));
return (Double) tmp / p;
introundDoubleToInt(final double VALUE)
round Double To Int
double dAbs = Math.abs(VALUE);
int i = (int) dAbs;
double result = dAbs - (double) i;
if (result < 0.5) {
    return VALUE < 0 ? -i : i;
} else {
    return VALUE < 0 ? -(i + 1) : i + 1;