numbers - Fixed decimal places double and power of ten format in java -


i'm writing code in java supposed manipulate data text file. in text file coordinates saved. layout of numbers always: 5.000000000000000+0 data read, manipulated , printed file. printing part not yet working, number of decimal places varies , haven't succeeded append power of ten in shown way. decimal numbers tried:

formatter.setminimumfractiondigits(15); 

and

formatter.setmaximumfractiondigits(15); 

but still displays more digits sometimes. how can achieve shown format double numbers or @ least right amount of decimal digits?

use string.format:

    double x = 1.1231523235;     system.out.print(string.format("%.5f", x)); 

that print

    1,12346 

and if want dot delimiter use

    system.out.print(string.format(locale.english,"%.5f", x)); 

Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -