Steve Waters Steve Waters - 8 months ago 48
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
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 Source

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);