thomaset2000
asked on
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
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
take the Round of 99.99999
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
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
ASKER
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 )
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.