round issue

Emile van Sebille emile at fenx.com
Tue Jul 13 12:39:18 EDT 2010


On 7/13/2010 9:06 AM Robin Becker said...
>
> Anyhow does anyone have a good algorithm for ensuring rounded
> percentages do add up to 100%? :) How about grouped percentages ie
> ensure the group sums and the groups display correctly in rounded form.

I generally do the calculations in memory then set the
largest to 100 - sum(rounded(others)).  (Same as for
double entry bookkeeping to ensure debits == credits)

Emile






More information about the Python-list mailing list