stripTrailingZeroes « bigdecimal « Java Data Type Q&A





1. Clarification on behavior of BigDecimal.stripTrailingZeroes()    stackoverflow.com

Why the following code prints 0.00 and not 0?

BigDecimal big = new BigDecimal("0.00");
big = big.stripTrailingZeros();
System.out.println(big.toPlainString());
The following is the documentation for stripTrailingZeroes:
Returns BigDecimal which is numerically equal to this one but with ...

2. Bug in BigDecimal.stripTrailingZeroes()?    forums.oracle.com

I've noticed that the stripTrailingZeroes() method of BigDecimal has no effect if the value is zero. I had a number with a value of "0.000000000", and I expected to get just "0" back, but the number I got back was the same as the number I started with. It works fine with any other number, just not zero itself. I can't ...