I came across an issue a couple of months ago, where I had received a bug report that the numbers in a report we were generating were incorrect. There were two percentages that when added together should have totaled to 100%.

To get this percentage we have very large numbers that are added together and used cast(sum(NUMBERS) AS varchar) to obtain them. I couldn't find any correlation with the size, but some of the numbers were returned by the query as scientific notation, so instead of getting 1227630000 we got 1.22763e009. We then required ColdFusion to do some more calculations to determine the percentages, but ColdFusion didn't know how to handle the scientific notion so it just didn't and we added 1.22763 instead of 1227630000, which is a huge difference when you are calculating values.

To fix this issue we just removed the cast around the sum statement.