Closed Thread Icon

Preserved Topic: Rounding percentages? Pages that link to <a href="https://ozoneasylum.com/backlink?for=21063" title="Pages that link to Preserved Topic: Rounding percentages?" rel="nofollow" >Preserved Topic: Rounding percentages?\

 
Author Thread
Sash
Paranoid (IV) Inmate

From: Canada, Toronto
Insane since: May 2000

posted posted 02-14-2002 05:22

I am doing this in Java, but I guess the problem is general.

Adding up the numbers bellow gives the number very close to 100:
35.692334025784064%
43.68197060585548%
16.863898419811868%
3.7617969485485765%

But if we round them up:
36
44
17
4
the sum is 101.
How do you get around this problem. What is the logic?

Thanks.

sasha &raquo;

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 02-14-2002 06:21

Simple explanation of the logic:

2.5 + 2.5 = 5

but

round(2.5) + round(2.5) = 3 + 3 = 6

It only comes back to the original number if the amount that numbers are rounded isn't too much up or too much down.

There's no real easy way around the problem except for not rounding the numbers.

Sash
Paranoid (IV) Inmate

From: Canada, Toronto
Insane since: May 2000

posted posted 02-14-2002 06:38

Thanks Slime, short and to the point.

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 02-14-2002 07:34

For the record, almost every voting software has this small *issue*. IMHO The easiest solution would be to fake one of the values, simply sum up all values except one and then you get that last value by subtracing sum of all other values from 100...

In your example:
36+44+17=97
100-97=3

And so we have the following values (which give 100):

36
44
17
3

BTW The end result may not be mathematically correct, but what the heck, we got 100 and that's what counts, heh...


« BackwardsOnwards »

Show Forum Drop Down Menu