java - NumberFormat without maximum fraction digits -
is there way create numberformat
instance no maximum fraction digits? obvious solution be
numberformat format = numberformat.getnumberinstance(); format.setmaximumfractiondigits(integer.max_value);
but i'm wondering if there's more definitive way of specifying there should no precision limit.
from numberformat api (http://docs.oracle.com/javase/7/docs/api/java/text/numberformat.html):
"setparseintegeronly
: affects parsing, e.g. if true, "3456.78" -> 3456 (and leaves parse position after index 6) if false, "3456.78" -> 3456.78 (and leaves parse position after index 8) independent of formatting."
i guess if call setparseintegeronly(false)
not worry precision limit, tho i'm kind of stretching facts one.
aha! here go:
numberformat nf = numberformat.getinstance(); nf.setroundingmode(roundingmode.ceiling);
then again, i'm not sure "rounding towards infinity" means. want one:
nf.setroundingmode(roundingmode.unnecessary);
http://docs.oracle.com/javase/7/docs/api/java/math/roundingmode.html
Comments
Post a Comment