I have a DecimalFormat object that I use to format all of my double values to a given number of digits (let them say 2) when I display them. I would like it to be usually up to 2 decimal places, but I always need at least one significant digit. For example, if my value is 0.2, then my formatter spills out 0.20 and this is wonderful. However, if my value is 0.000034, my formatter will spit out 0.00, and I would prefer my formatter to spit out 0.00003.
The number of formatters in Objective-C makes it very simple, I can just set the maximum number of digits that I want to show to 2, and the minimum number of significant digits to 1, and it gives my desired result, but how can I do it in Java?
I appreciate any help anyone can offer me.
Kyle
Edit: I'm interested in rounding values, so 0.000037 is displayed as 0.00004.
source
share