News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Poll results percentages

Started by Ben_S, June 03, 2004, 08:39:53 AM

Previous topic - Next topic

Ben_S

The results of poll votes dont seem to add upto 100%. A poll running on my board has just been mentioned on the radio, they also saw fit to mention that the results added up to 103%.
Liverpool FC Forum with 14 million+ posts.

Daniel D.

That's a known problem since YaBB Gold ??? or SE. If I remember right, the reason are the rounded numbers.

Christian Land

Try what happens if you replace:

'percent' => round($bar, $precision),

with

'percent' => round(($option[1] * 100) / $divisor, $precision),

in Display.php

Ben_S

Quote from: Daniel D. on June 03, 2004, 08:42:00 AM
That's a known problem since YaBB Gold ??? or SE. If I remember right, the reason are the rounded numbers.

Aye, certainly been there a while, just thought it was funny hearing it on the radio.

Quote from: SnowCrash on June 03, 2004, 09:02:26 AM
Try what happens if you replace:
<>

Will try it when I finnish work.
Liverpool FC Forum with 14 million+ posts.

Ben_S

Quote from: SnowCrash on June 03, 2004, 09:02:26 AM
Try what happens if you replace:

'percent' => round($bar, $precision),

with

'percent' => round(($option[1] * 100) / $divisor, $precision),

in Display.php

That fixes it :).
Liverpool FC Forum with 14 million+ posts.

Christian Land


[Unknown]

 ! The percentages for a poll now add up a little better.

(I changed a different part, but basically the same way.)

-[Unknown]

Skoen

Noticed that too. In a poll where there are 24 votes in it, the total percent is 97% instead 100%. Might try the fix myself, and that made the total to be 99,9% :P
Alf Otto 'Skoen' Fagermo
Retired Norwegian translator


Christian Land

The problem is, that there will always be situations where you won't get a correct result....

But with the fix, the difference to 100% will be smaller.... so i guess its OK... ;D

Springer

How far does it carry a number before it rounds?

Christian Land

Quote from: Springer on June 04, 2004, 03:50:59 PM
How far does it carry a number before it rounds?

The round function only uses a precision of 1... so all numbers get rounded at the first digit after the decimal point. I tested the above fix a little bit, and all my tests gave results between 99,9% and 100%... and it really doesn't matter with what precision the values get rounded... there are situations where the percentages are always false...

for example: 3 people vote for 3 different options... you will always end up with wrong numbers... the current beta of SMF displays 33% for each option... the fixed version will show 33,3%.... even if you change the precision to 1000, you'll still get the same result.... so who cares?

Advertisement: