List of utility methods to do Decimal Round
double | truncate(double d, int digits) truncate NumberFormat nf = NumberFormat.getInstance();
nf.setMaximumFractionDigits(digits);
nf.setGroupingUsed(false);
return Double.parseDouble(nf.format(d));
|
double | truncate(final double v, final int sigNumIndex) Format the passed in double number by dropping off the less significant numbers so that the least significant number is indicated by the passed in sigNumIndex. if (sigNumIndex >= 0) { return ((int) (v / Math.pow(10, sigNumIndex))) * Math.pow(10, sigNumIndex); final NumberFormat nf = NumberFormat.getNumberInstance(); nf.setGroupingUsed(false); nf.setMaximumFractionDigits(Math.abs(sigNumIndex)); return Double.parseDouble(nf.format(v)); |