0

I want to round value with 5 decimal place.

I've tried Math.round(x * 10000) / 10000 but it doesn't work.

nyedidikeke
  • 6,899
  • 7
  • 44
  • 59
P.I
  • 3
  • 4
  • 4
    Possible duplicate of [Round to at most 2 decimal places (only if necessary)](https://stackoverflow.com/questions/11832914/round-to-at-most-2-decimal-places-only-if-necessary) – nyedidikeke Jul 25 '18 at 16:33
  • If you are rounding to 5 places, you might want to multiply and divide by something with 5 zeros. – JonSG Jul 25 '18 at 17:21

1 Answers1

0

You can try below code for more precious rounding, generally we use these to calculate insurance data:

BigDecimal decimal = new BigDecimal(100);
decimal.round(new BigDecimal(10000).setScale(5,BigDecimal.ROUND_DOWN);

Be careful in choosing the ceiling option. Refer big-decimal for more options.

mx0
  • 6,445
  • 12
  • 49
  • 54
Sundar
  • 16
  • 2