Hi everybody,
It turned out that the whole 31 cents difference belongs to the particular record. I recalculated the commissions for it based on the current values in the tables and my numbers are correct. I'm not sure why do we have a value in the table for 31 cent more.
BTW, I changed my algorithm slightly, I also changed from currency fields to Numeric 9,2, but the discrepancy remains the same. In the report I added in red the number of discrepancies and the individual invoice calculations for difference >0.01 (originally I used 0.5 to filter other problems).
Once I've done it, I saw this bad record immediately.
>>Fabio,
>>
>>The trouble is that there are already precalculated values in a N(9,2) field. I was just trying to show the sorts of cumulative rounding errors that can result.
>>
>
>John,
>
>Ok.
>
>>I've seen it before- when using a UK copy of Quickbooks in Australia or New Zealand, sales tax is calculated wrongly because it is calculated on a line-by-line basis rounded to 2 decimal places, giving cumulative rounding errors, rather than as single calculation of the grand total.
>>
>>Naomi, if you do simple numeric math adding the N(9,2) values in your table, you should not see error.
>
>This is the point.
>This is true into the 99.99999% of the cases, because when VFP uses a N(9,2) it convert the number
>to a Floating point variable, and the sum is done into a floating point accumulator.
>
>>If you are recalculating the commission into a currency field, however, the extra 2 decimal places will cause repeated small discrepancies that may add to several cents.
>
>A round(,2) into the process it would owe to fix the issue.
If it's not broken, fix it until it is.
My Blog