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

doubleround(double number, int digits)
round
if (digits > 6) {
    return number;
} else {
    double roundNumber = number;
    roundNumber *= Math.pow(10, digits);
    roundNumber = Math.round(roundNumber);
    roundNumber /= Math.pow(10, digits);
    return roundNumber;
...
doubleround(double number, int places)
round
assert places > 0;
final double multiplier = Math.pow(10, places);
return (int) (number * multiplier) / multiplier;
doubleround(double number, int places)
Rounds a number to the given number places.
final double power = Math.pow(10, places);
number = number * power;
final double value = Math.round(number);
return value / power;
doubleround(double number, int precision)
round
int power = (int) Math.pow(10, precision);
double num2 = Math.round(number * power);
return num2 / power;
Doubleround(Double number, Integer precision)
round
Double retObj = null;
if (number != null) {
    if (precision == null)
        precision = 0;
    Double decimalPlaces = Math.pow(10, precision);
    retObj = (double) Math.round(number * decimalPlaces) / decimalPlaces;
return retObj;
...
Objectround(Double ret, Integer doublePrecision)
round
return null;
doubleround(double round, int decimal, int ceilOrFloor)
round
round *= (Math.pow(10, decimal));
if (ceilOrFloor == 0) {
    round = Math.ceil(round);
} else {
    round = Math.floor(round);
round /= (Math.pow(10, decimal));
return round;
...
int[][]round(double Rpred[][])
Round - simply round numbers (e.g., 2.0 to 2) -- for multi-target data (where we don't *yet* use a threshold).
int Ypred[][] = new int[Rpred.length][Rpred[0].length];
for (int i = 0; i < Rpred.length; i++) {
    for (int j = 0; j < Rpred[i].length; j++) {
        Ypred[i][j] = (int) Math.round(Rpred[i][j]);
return Ypred;
doubleRound(double Rval, int Rpl)
Roundoff method.
float p = (float) Math.pow(10, Rpl);
Rval = Rval * p;
float tmp = Math.round(Rval);
return (double) tmp / p;
doubleround(double toRound)
Rounds to two decimals.
return Math.round(toRound * 100.0) / 100.0;