List of utility methods to do Double Number Round
Double | round(final Double value) round if (value != null) { return Math.floor(value.doubleValue() + 0.5d); return value; |
Float | round(final Double value) Round to 0.x if (value != null) { return (float) (Math.round(value * TEN)) / TEN; return null; |
double | round(final double value, final int numDecimals) round final double factor = Math.pow(10.0, numDecimals); return Math.round(value * factor) / factor; |
double | round(final double x, final int digits) rounds up a double up to the specified number of digits after period. final double d = Math.pow(10, digits); return Math.round(x * d) / d; |
int | round2(double d) Useful for hashCode() and equals() fn's that compare stuff read from a text file. return (int) (d * 100 + 0.5); |
double | round2(double num) round double result = num * 100; result = Math.round(result); result = result / 100; return result; |
double | round2(final double arg) Returns the input argument, rounded to two decimal places. double d = arg * 100.0; final long longArg = Math.round(d); return longArg / 100.0; |
int | round2(int a, int preserveDigits) Math#round(double) -like operation for integers preserving the given number of digits in contrary to MathUtil#round(int,int) where cut-of-digits are specified: return round(a, getDigits(a) - preserveDigits)
return round(a, getDigits(a) - preserveDigits);
|
Double | round2Places(Double input) round Places return Math.round(input * 100.0) / 100.0;
|
double | round5(final double value) round return Math.round(value * 100000.) / 100000.;
|