Post Reply 
Rounding approach
04-12-2014, 07:29 PM
Post: #1
Rounding approach
My question is indirectly related to calculators since they have a finite number of decimal places. I am working on a software that does price calculations. Typically you have 2 decimal places and you may think it will be easy to implement. Unfortunately there are a number of things you can do, like rebates, exchange rates, quantity, price total, price each, sometime forward or backward calculations (i.e. start from net price or from discount). After a couple of divisions, multiplications and rounding at each step, chaos comes and it is hell to ensure that the price and all the details are consistent. Then you can expect sarcasms regarding your inability to program a simple sum...

Another common issue causing programs to crash being that when you expect zero you may find very small values so you would find yourself testing abs(value) < epsilon instead of value == 0.

I was wondering if there was a theory (or at least libraries or algorithms) to handle that properly?
Find all posts by this user
Quote this message in a reply
Post Reply 

Messages In This Thread
Rounding approach - Tugdual - 04-12-2014 07:29 PM
RE: Rounding approach - Joe Horn - 04-13-2014, 06:44 AM
RE: Rounding approach - Paul Dale - 04-13-2014, 09:16 AM
RE: Rounding approach - Dieter - 04-13-2014, 11:41 AM

User(s) browsing this thread: 1 Guest(s)