trim « bigdecimal « Java Data Type Q&A

1. How do you trim the BigDecimal division results

BigDecimal numerator = new BigDecimal(numerator);
BigDecimal denominator = new BigDecimal(denominator);
double result = numerator.divide(denominator).doubleValue();
Division on certain conditions results in a zero at the end (e.g. 0.0060). Dividing equal numbers results in a zero ...

2. Trim More than two trailing Zeros in BigDecimal

What would be a good way to trim more than two trailing zeros for a BigDecimal So 1.2200 would print 1.22 and 1.0000 would print 1.00 Edit As well as to return 1.222200 ...

3. Remove leading zero and delimiter char for BigDecimal

Our application can get following numbers:
etc. These values treated by our code as BigDecimal,as far we operate with money. There is form on web UI, where user should view these floating parts of ...