List of utility methods to do Number Round
double | roundToDecimalPlaces(final double val, final int places) Returns the given value rounded to the given precision. final long power = (long) Math.pow(10, places); return ((long) (val * power + 0.5)) / (double) power; |
double | roundToDecimals(double d, int c) Rounds the given double to the given number of decimals int temp = (int) ((d * Math.pow(10, c))); return (((double) temp) / Math.pow(10, c)); |
double | roundToDecimals(double d, int c) round To Decimals double denom = Math.pow(10, c); return Math.round(d * denom) / denom; |
double | roundToDecimals(double d, int c) Returns a value with the desired number of decimal places. if (c < 0) return d; double p = Math.pow(10, c); d = d * p; double tmp = Math.round(d); return tmp / p; |
double | roundToDecimals(double d, int numberOfDecimalPlaces) round To Decimals int temp = (int) ((d * Math.pow(10, numberOfDecimalPlaces))); return (temp / Math.pow(10, numberOfDecimalPlaces)); |
double | roundToDecimals(double d, int percision) Round a double to the given number decimal places double p = (double) Math.pow(10, percision); return (double) Math.round(d * p) / p; |
double | roundToDecimals(double doubleValue) round To Decimals return (roundToDecimals(doubleValue, 6));
|
double | roundToDecimals(double input, int places) round To Decimals double log10 = Math.log10(input); double intLog10 = Math.floor(log10); double scale = Math.pow(10, intLog10 - places + 1); double factored = Math.round(input / scale) * scale; return factored; |
double | roundToDefaultPrecision(final double value) round To Default Precision return (long) (P_ROUNDING_FACTOR * value + 0.5) / P_ROUNDING_FACTOR; |
int | roundToDimensions(int value, int f) Round. return Math.round(value / f) * f;
|