1
I wrote the following method:
public static double round(double value, int scale) {
BigDecimal bd = new BigDecimal(value);
bd.setScale(scale, BigDecimal.ROUND_HALF_UP);
return bd.doubleValue();
}
I make the call:
round(72.46976811594203, 2)
And get the following output:
72.46976811594203
I would like it to be returned 72.47 as I am rounding to two decimal places. Where is the error?
I really made a big mistake. I didn’t notice that setScale() returned the result. Thankful!
– Herik R