Solved

# Proportionately distribute (prorate) a value

Posted on 2011-04-25
Medium Priority
598 Views
I have a problem on defining the allocation number.
let say i have number 100 and it will be allocated to 3 users.
based on the situation , the formula should be 100 devided by 3. Using that formula it will result 33.33333. When i sum the calculated value it will result 99.99999, how do i prorate the number (e.g 100) so when i sum back the prorated number , it will result the original number (e.g 100).

Thanks
0
Question by:thomaset2000

LVL 39

Expert Comment

ID: 35458716
take the Round of 99.99999
0

LVL 16

Expert Comment

ID: 35458725
Hi,

It is generic arithmetic problem and you can come over it by Math.Round.

in C# you can use it as following
double Value = 100;

double v1, v2, v3;
v1 = v2 = v3 = Value / 3;

double total = Math.Round(v1 + v2 + v3, 2);

Thanks
0

Author Comment

ID: 35458741
is there a way , to have a formula that worked without rounding the final result ( e.g the allocation should be 33.3333 , 33.3333, 33.3334 )
0

LVL 16

Accepted Solution

Imran Javed Zia earned 1000 total points
ID: 35458758
Hi,

You can use something like following:

double Value = 100;

double v1, v2, v3;
v1 = v2 = Value / 3;
v3 = Value - v1 -v2;

double total = v1 + v2 + v3;

Thanks

0

LVL 71

Expert Comment

ID: 36032523
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recursive SQL is one of the most fascinating and powerful and yet dangerous feature offered in many modern databases today using a Common Table Expression (CTE) first introduced in the ANSI SQL 99 standard. The first implementations of CTE began ap…
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
###### Suggested Courses
Course of the Month15 days, 16 hours left to enroll