I have BigDecimal
values and I want to have them at least two decimal digits, but I don't want to trim the rest.
So 3
should result in 3.00
, but 3.001
should stay 3.001
.
I know that I can do this by simply adding 0.00
:
new BigDecimal("3").add(new BigDecimal("0.00")) //=> 3.00
new BigDecimal("3.001").add(new BigDecimal("0.00")) //=> 3.001
Is there a build in method or a more elegant way to do this?
I can't use setScale
, because I want to keep additional decimals when they exist.