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

前端 未结 14 852
一整个雨季
一整个雨季 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:06

    This will work as long as your number is a whole number:

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

    If the double variable has precision after the decimal point it will truncate it.

提交回复
热议问题