List of utility methods to do Double Number Round
double | roundDoubleToPlace(double d, int place) round Double To Place if (place < 0) throw new IllegalArgumentException(); if (place > 9) throw new IllegalArgumentException(); long factor = (long) Math.pow(10, place); return ((double) Math.round(d * factor)) / factor; |
double | roundDoubleValue(double value) Rounds a double value to the first two digits. double roundedValue = Math.round(value * 100) / 100.0; return roundedValue; |
int | roundDown(double a) Returns the closest int to the argument, with ties rounding down. double r = a % 1; if (r < 0) r += 1; return r == 0.5 ? (int) Math.round(a) - 1 : (int) Math.round(a); |
double | roundDown(double amt, double digits) round Down double powValue = Math.pow(10, digits); amt = amt * powValue; amt = ((int) amt); amt = amt / powValue; return amt; |
int | roundDown(double n) Round the given number to the nearest whole that is smaller than the number. return (int) n; |
double | roundDown(double num) round Down return Double.valueOf(String.format("%.2f", num)); |
double | roundDown(double val, int decimals) Cut a value to given number of decimals. double pow = Math.pow(10, decimals); return Math.floor(val * pow) / pow; |
double | roundDown(double value, double units) round Down double scaled = value / units; return Math.floor(scaled) * units; |
int | roundDown(double value, int gridSize) round Down return (int) (Math.floor(value / gridSize) * gridSize); |
int | roundDown(final float realNumber) Round the number down to the closest integer return (int) Math.round(Math.floor(realNumber)); |