0

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

Lina
  • 305
  • 1
  • 6
  • 15

1 Answers1

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