Page 1 of 1

Dividing up money?

Posted: Fri Aug 25, 2006 2:05 pm
by Ward
I'm currently working on an app that divides up commissions between users. I have a table of percentages, which determines how much each user gets. For example, Let's say someone makes a $100 sale. He gets 80%, another user gets 15%, and another gets 5%. In this example the math is easy, but the tables are much more complicated than that.

I need a way to exactly divide up an amount by percentages. The sum of all pieces must equal the original sale amount. I think my problem lies in the floating point dollar amounts I am winding up with, and some sort of rounding taking place. Any ideas?

Posted: Fri Aug 25, 2006 2:28 pm
by Ward
Well, I found the problem. One of my percentage tables added up to 99.9% instead of 100%. That was causing some the division inaccuracies.