Reputation: 97
I have problem in dealing with scientific notation. In order to simplifeid problem, I used constants instead of variables, and the statement as follows :
double temp = 211.751 * 110 * 500 * 0.9971;
Log.e("Temp : ", Double.toString(temp));
the result is : 1.1612530715499999E7
what I want is : 11,612,530.72
My question is how to convert the result into normal expression and formatted to 2 decimal places.
Upvotes: 2
Views: 21482
Reputation: 24848
// try this
double temp = 211.751 * 110 * 500 * 0.9971;
DecimalFormat format = new DecimalFormat("#00,000,000.00");
Log.e("Temp : ",format.format(temp));
Upvotes: 0
Reputation: 2486
Double.parseDouble("9.78313E+2");
gives you
978.313
and then
NumberFormat formatter = new DecimalFormat("#0.00");
System.out.println(formatter.format(number));
try it out
Upvotes: 9