09-18-2009 04:46 PM
I am tring to convert a double 24,000,000.00 to String. But I got a string "2.4E7".
Does anybody knows how can I avoid this scientific notation issue?
Solved! Go to Solution.
09-19-2009 06:57 PM - edited 09-19-2009 06:59 PM
Could you paste the code to how you are converting so that I may offer up an alternative?
If not what I always do to keep things simple is add something to a blank string ie
String doubleString = ""+ doubleValue;
it wont have the formatting of commas and decimal wont be rounded to two digits (i think),
someone else may be able to offer up a much better solution, but you could give this a try if you can't come up with anything else
09-20-2009 12:37 PM
Sorry johnbibs, I think you missed the first post in this Thread.
If you do something like
double d = 24000000.00d;
String sd = Double.toString(d);
you will get a String in Exponential format, "2.4E7" in this case, but the OP wants it fully spelt out.
09-20-2009 02:45 PM
Have you tried casting to an int? something like:
double d = 24000000.0;
int i = (int)d;
String s="" + i;
Then just add the remainder to your string to get the precision that you would want...
double remainder = d - i;
remainder = remainder*100;
s+= "." + (int)remainder;
You would lose a little precision due to rounding problems, but you could use the rounding functions in the api to get a closer answer.
09-21-2009 06:40 AM
I have doubt about balckberry browser . i will give thread link for you
can you please help me..
09-21-2009 06:49 AM
@ kumaresan - hijacking another Thread is extremely impolite, probably worse than the impatience I suggested you were showing when I responded to your Thread earlier.
Can I suggest that you review the following:
It will give some hints as to the best ways to use forums like this. And please don't post an apology on this Thread - just don't do it again!