Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Where should ROUND() be applied in complex calc
Message
From
24/04/2009 21:29:16
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01396309
Message ID:
01396349
Views:
65
This message has been marked as a message which has helped to the initial question of the thread.
>Hi all
>
>There are some complex tax calculations to be performed. For eg. Excise is calculated on an abatement provided value of the Maximum Retail Price (MRP) of a products. Two more taxes are then calculated on this Excise amount. Assuming the client is going to ROUND() at 0 precision - no decimal places.

My experience with things like that tells me to forget the maths, logic and common sense, and simulate the manual process the accountants will use to check your calculations, so you get the same result as they do. Anything else will be an error to them.

From the same set of long afternoons and evenings with accountants in my wilder days: calculate the tax per item only once, and _store it_. Never calculate again. Never calculate tax on the total of multiple items, the calculation will be more precise and your tax total will be different from the sum of tax amounts per item. The accountants will take this as evidence that your program does something wrong. Calculate once, store, then sum. No matter how you sum it, the sum will be the same - no roundoff error there, you're clean.

As to your specific calculation, you can achieve the best accuracy if you round up only the final result, but it won't matter a bit if they add it this way and that way and it doesn't match. It's accountants we're talking about, is it?

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform