Steve Waters Steve Waters - 8 days ago 6
Java Question

How to format a double so, that it will never show scientific notation?

I want to format a double so, that there's no scientific notation (the E letter) showing when I have a number larger than a million or so.

I have already formatted the double to have only two decimals.

as in

DecimalFormat dFormat = new DecimalFormat("0.00");


but even with that, I'm seeing
10007999.00
as
1.001511661E7
on the screen.
I don't want to see it in that form (can't really think of why anyone would...)

How to format the double so, that it is showing as a normal number, not some letters in it. Thank you.

Answer

A 5-minute search on Google brought me here: How to print double value without scientific notation using Java?

This is what you want right?

Here's the same thing, but in a function:

public static String dNoScience(double d) {
    return String.format("%.0f\n", d);
}