Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question About Calculating Money With Fractions

Status
Not open for further replies.

anon47

Programmer
Nov 28, 2006
80
US
The calculation is as follows:

I am trying to build a new system out of MS SQL with a totally web based ASP front end and before I start I want to figure out which calculation produces the most accurate data at high figures and to the penny. It appears the fraction is more accurate when dealing with splitting money three or more ways. I am structuring this system on paper before building it. This has proven to be the best way for me rather than building as I go and having a lot of unnecessary code and functions.

Here is how it works, lets say you have $1,300.00 payment and Person One gets a total of $250.00; Person Two Gets a Total Of $750.00; and Person Three Gets a total of $300.00. To make this happen on every payment made, and ensure every person gets exactly what is owed you would have the following percentage and fraction calculation. Let me add this explanation of how and why I need it like this: person one only gets 25% of $1,000.00 and person two gets 75% of that same $1,000.00 and person three gets 30% of that $1000.00 but his 30% or 1/3 is added to the top of the $1,000.00 making it $1,300.00. Now every payment that comes in there is a fraction or a percentage used to calculation exactly how much should be paid to the three people so at the end of payments everyone has gotten every penne owed to them. We currently use percentages but they tend to be accurate but sometimes leave a penny + or -. The fractions seem to eliminate this.

My question is, Is fractions more accurate than percentages? If so why?


Fraction Cal
Person One: 5.2
Person Two: 1.7333333333333333333333333333333
Person Three: 4.3333333333333333333333333333333

Or

Percentage Cal
Person One: 0.19230769230769230769230769230769
Person Two: 0.57692307692307692307692307692308
Person Three: 0.23076923076923076923076923076923



First Test: Random Person Three

Percentage Cal: $987,456,321.00 * 0.23076923076923076923076923076923 = $227,874,535.84384615384615384615362

Fraction Cal: $987,456,321.00 \ 4.3333333333333333333333333333333 = $227,874,535.84384615384615384615386



Second Test Person Three: The calulation is to see which ia moat accurate to $300,000,000.00

Percentage Cal: $1,300,000,000.00 * 0.23076923076923076923076923076923 = $299,999,999.9999999999999999999997

Fraction Cal: $1,300,000,000.00 \ 4.3333333333333333333333333333333 = $300,000,000.00000000000000000000002
 
I don't quite understand your fraction cal. As fractions

Person 1: 250/1300
Person 2: 750/1300
Person 3: 300/1300

As Percentages

Person 1: 250/13 = 19.23%
Person 2: 750/13 = 57.69%
Person 3: 300/13 = 23.07%

i.e. same as fractions, just multiplied by 100. There is no difference.
 
Use scaled long integers for all money calculations rather than FP

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
xwb

to get the fraction of it u do:

Person 1: 1300.00/250.00 = 5.2
Person 1: 250.00/1300.00 = 0.19230769230769230769230769230769


You have to have the complete percentage framwork in the calulation else at high numbers you will be off by sometimes dollars.

What I was needing to know if fraction calulate more accurate than percentages. I believe they do so I am going to just write my code useing the same. Thanks guys
 
thanks john for the response, and we do use the long integers even in our data system now this is the only way to go using whole number as they contain a lot of charters
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top