Apex document clearly says, Scientific notation (e) for Doubles is not supported. But again, Salesforce Object Reference guide says, Values can be stored in scientific notation if the number is large enough, or small enough negative. So, here is the ambiguity.

As per my experience and knowledge in Salesforce, when I re-read the statements it seems they are correct. But I wanted to confirm the same here, if my analysis is correct.

So, the actual meaning of the above statements is "yes, double values does not allow scientific notations, and even double type fields (Currency, Percent) does not allow user to enter scientific notation as value in UI. But, internally if the value is too small or large then the value can be stored as scientific notation in database, and it may return the value in scientific notation when retrieved in dataloader"

Correct me if I am wrong, and clarify the ambiguity.

Thank you.

1 Answer 1


Yes, apex does not allow scientific notation in double, which means you cannot assign scientific notation value to a double variable as shown below

Double d = -2.347774E-10;


sObjRec.CurrencyField__c = -2.347774E-10;

But there is a workaround for this as shown below

Double d = Double.valueOf('-2.347774E-10');
sObjRec.CurrencyField__c = Double.valueOf('-2.347774E-10');

But user can enter scientific notation value( for example, -2.347774E-10 but not -2.347774e-10) in UI for sObject double type fields such as Currency and Percent fields.

Regarding retrieving the double type fields data, yes, when they are retrieved from dataloader or workbench they can be retrieved in scientific notation. The same applies for SOQL queries also.

In an Apex program, the double value retrieved as Currency/Percent sObject field value can be used and assigned to a double variable(or field) regardless of whether the value is in scientific notation or not. For example,

sObject sObjRec = [Select CurrencyField__c FROM Account limit 1];
Double d = sObjRec.CurrencyField__c; //is possible
//But remember, Double d = -2.347774E-10; is not possible as explained above.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .