A
A
artshelom2018-03-27 17:03:40
Java
artshelom, 2018-03-27 17:03:40

How to change Double format??

My Double outputs: 2.189E-5
And you need all the decimal places. How to change the format?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mshadow, 2018-03-27
@artshelom

Here is an example of double output formatting

double pi = Math.PI;
 
      System.out.format("%f%n", pi);       // -->  "3.141593"
      System.out.format("%.3f%n", pi);     // -->  "3.142"
      System.out.format("%10.3f%n", pi);   // -->  "     3.142"
      System.out.format("%-10.3f%n", pi);  // -->  "3.142"
      System.out.format(Locale.FRANCE,
                        "%-10.4f%n%n", pi); // -->  "3,1416"

in details

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question