+ Start a Discussion
WizradWizrad 

Double -> Strings and preventing scientific notation

Hi all,

 

I see that if I use String.valueOf() or '' + on a Double that has 8 digits or more, it turns it into scientific notation.

 

Is there any way to prevent this?  I see that a .format() works, but that adds commas.  I can replace the commas with empty string, but this only works in my locale.

 

Am I really being forced to split on capital E, take the number after the E, and tack on the appropriate amount of zeros?  There must be a better solution.

 

Thanks!

jeremyyjeremyy

Ideally there would be a method like:

 

 

static String.format(String, List<Object>) 

 in the style of javadoc.

 

 

However, Apex doesn't have Object (or anything AFAIK) at the root of its object hierarchy, so the actual method that Apex has is 

 

 

static String.format(String, List<String>) 

which is fairly useless. Hopefully someone can shed some light.