I want to do rounding of Bigdecimal e.g my 0.1 then it should round as 1. I tried with Round_UP, all Rounding Function Please help me out
Asked
Active
Viewed 45 times
0
-
https://stackoverflow.com/questions/4134047/java-bigdecimal-round-to-the-nearest-whole-value , does this answer your question ? – Pradeepal Sudeshana Oct 24 '20 at 06:10
1 Answers
1
I suppose you used the round
method. Instead, you should change the scale to 0
.
BigDecimal bd = BigDecimal.valueOf(0.1);
BigDecimal rounded = bd.setScale(0, RoundingMode.UP); // 1

Glains
- 2,773
- 3
- 16
- 30