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

mysql - FireDac error 314 - but DLLs are in program directory -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -

java - How can I send the data from a imput type="file" to the controller? -