I created a rollup summary field "One Off Charge" that will summarize the currency field of the child records. I encountered a problem where on the UI, its showing 10,000.00 but when I tried to get the value by querying it from apex, I got 9999.9999999999999

enter image description here

enter image description here

I check the source (Custom object named "Attribute") of this rollup summary field and i only have 1 child records with 10000 price value.

enter image description here

Then tried to run a query in anonymous. The source value is okay, but the rollup summary is 9999.999999

enter image description here

Anyone can explain why?

1 Answer 1


This is very likely all to do with how floating point numbers are represented on computers. You'll find detail on wikipedia, which shows how only a sub-set of numbers can be accurately represented in computers.

It is often the case that an approximated representation is rendered by rounding it for decimal presentation. However, it looks like this rounding isn't being applied in your case. It may be that the number of decimal places (what Salesforce calls the "scale", take a look at Decimal.setScale for more) is set differently on your two variables so any rounding varies.

You must log in to answer this question.

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