java.math.BigDecimal.toString() can return something like “0.888200000”. What can be the best I can do if I want “0.8882” instead? I can never know (unless I calculate it for every particular case) the length of the integer (left to the point) part, the value can be 123.8882 as easily as 123456.88.
java.math.BigDecimal.toString() can return something like 0.888200000. What can be the best I can do
Share
Use
stripTrailingZeros():See http://docs.oracle.com/javase/1.5.0/docs/api/java/math/BigDecimal.html