Does anyone have experience using BNF in DecimalFormat?
http://java.sun.com/docs/books/tutorial/i18n/format/decimalFormat.html
See under “Number Format Pattern Syntax”
As I wish to convert from double to string as follow :
0.10 -> "0.1"
0.110 -> "0.11"
0.11...10 -> "0.11...1"
Currently, I am using
DecimalFormat decimalFormat = new DecimalFormat("0.#############################");
I just feel that it is not a very smart way. I wish to specific, “has 1 or more #”
The maximum number of digits to the right of the decimal point in double-precision arithmetic is 17, I believe, so just construct a DecimalFormat like
0.#################.