I want to print a double value in Java without exponential form.
double dexp = 12345678; System.out.println("dexp: "+dexp);
It shows this E notation:
I want it to print it like this:
What is the best way to prevent this?
You could use
double dexp = 12345678; System.out.printf("dexp: %fn", dexp);
This will print
dexp: 12345678.000000. If you don’t want the fractional part, use
System.out.printf("dexp: %.0fn", dexp);
%.0f means 0 places in fractional part i.e no fractional part. If you want to print fractional part with desired number of decimal places then instead of 0 just provide the number like this
%.8f. By default fractional part is printed up to 6 decimal places.
This uses the format specifier language explained in the documentation.
toString() format used in your original code is spelled out here.