What you have done is correct. You're printing the number in science notation.
Instead of System.out.print()
use the following:
double d = Double.parseDouble(string)
System.out.printf("dexp: %f\n", d);
If you have pasted the whole value of your double you would see that there is E
almost at the end of the printed value. It stands for multiplied by 10 to the power of
and there is the exponent.
What's important isn't what is being printed but rather what's in the memory. The value stored in d
is correct. The printed value might have many useless trailing zeroes.
You can also use the DecimalFormat
class:
DecimalFormat df = new DecimalFormat("0", DecimalFormatSymbols.getInstance(Locale.ENGLISH));
System.out.println(df.format(d));