Proportionately distribute (prorate) a value

Posted on 2011-04-25
Medium Priority
Last Modified: 2012-05-11
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).

Question by:thomaset2000
LVL 39

Expert Comment

by:Pratima Pharande
ID: 35458716
take the Round of 99.99999
LVL 16

Expert Comment

by:Imran Javed Zia
ID: 35458725

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);


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 )
LVL 16

Accepted Solution

Imran Javed Zia earned 1000 total points
ID: 35458758

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;


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.

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question