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 val, long dec)
round
double erg, p;
p = Math.pow(10.0, (double) dec);
erg = Math.floor(val * p + 0.5) / p;
return erg;
intround(double valor)
DOCUMENT ME!
if ((valor - ((int) valor)) >= 0.5)
    return (((int) valor) + 1);
else if ((int) valor == 0)
    return 1;
else
    return (int) valor;
intround(double value)
round
int roundedValue = value > 0 ? (int) (value + 0.5) : -(int) (Math.abs(value) + 0.5);
return roundedValue;
doubleround(double value)
round
return Math.round(value * 10000) / 10000.0;
intround(double value)
Rounds a double to the next nearest integer value.
int roundedValue = value > 0 ? (int) (value + 0.5) : -(int) (Math.abs(value) + 0.5);
return roundedValue;
longround(double value)
Rounds the given double value
if (value < 0) {
    return (long) (value - 0.5);
} else {
    return (long) (value + 0.5);
longround(double value)
Rounds the given double value
if (value < 0) {
    return (long) (value - 0.5);
} else {
    return (long) (value + 0.5);
doubleround(double value)
round
final double NUMBER_OF_DIGITS = 1E5;
return (double) Math.round(value * NUMBER_OF_DIGITS) / NUMBER_OF_DIGITS;
Stringround(double value, double decimalplaces)
Rounds value.
double mult = Math.pow(10.0, decimalplaces);
return String.valueOf(Math.round(value * mult) / mult);
doubleround(double value, double factor)
Round the value to the nearest factor.
return (Math.round(value / factor) * factor);