# Proportionately distribute (prorate) a value

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
###### Who is Participating?

Consultant Software Engineer - .NET ArchitectCommented:
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

Commented:
take the Round of 99.99999
0

Consultant Software Engineer - .NET ArchitectCommented:
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 Commented:
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

Batchelor, Developer and EE Topic AdvisorCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.