How do I print a double value without scientific notation using Java?

前端 未结 14 1121
一整个雨季
一整个雨季 2020-11-21 11:52

I want to print a double value in Java without exponential form.

double dexp = 12345678;
System.out.println(\"dexp: \"+dexp);

It shows this

14条回答
  •  无人及你
    2020-11-21 12:13

    I think everyone had the right idea, but all answers were not straightforward. I can see this being a very useful piece of code. Here is a snippet of what will work:

    System.out.println(String.format("%.8f", EnterYourDoubleVariableHere));
    

    the ".8" is where you set the number of decimal places you would like to show.

    I am using Eclipse and it worked no problem.

    Hope this was helpful. I would appreciate any feedback!

提交回复
热议问题