List of utility methods to do Double Round
String | round(double d, int decimalPlace) round DecimalFormat df = new DecimalFormat(); df.setMaximumFractionDigits(decimalPlace); df.setMinimumFractionDigits(decimalPlace); return df.format(d); |
double | round(double value) round return ((int) (value * 10) / 10.0); |
double | round(double d, int decimalPlace) round try { BigDecimal bd = new BigDecimal(Double.toString(d)); bd = bd.setScale(decimalPlace, BigDecimal.ROUND_HALF_UP); return bd.doubleValue(); } catch (NumberFormatException e) { return d; |
double | round(double val, int numberOfDigitsAfterDecimal) round double p = (float) Math.pow(10, numberOfDigitsAfterDecimal); val = val * p; double tmp = Math.floor(val); return (double) tmp / p; |
double | round(double what, int howmuch) round return (double) ((int) (what * Math.pow(10, howmuch) + .5)) / Math.pow(10, howmuch); |
double | roundTwoDecimals(double d) round Two Decimals DecimalFormat twoDForm = new DecimalFormat("#.##"); return Double.valueOf(twoDForm.format(d)); |
BigDecimal | round(double number, int decimal) round return new BigDecimal(number).setScale(decimal, BigDecimal.ROUND_HALF_UP); |
String | convertDecimal(double d) convert Decimal DecimalFormat df = new DecimalFormat("#.0000"); return df.format(d); |
String | twoDecimalDoubleFormatter(double number) two Decimal Double Formatter return String.format("%.2f", number); |