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%.
That's a known problem since YaBB Gold ??? or SE. If I remember right, the reason are the rounded numbers.
Try what happens if you replace:
'percent' => round($bar, $precision),
with
'percent' => round(($option[1] * 100) / $divisor, $precision),
in Display.php
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.
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 :).
Fine ;D
! The percentages for a poll now add up a little better.
(I changed a different part, but basically the same way.)
-[Unknown]
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
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
How far does it carry a number before it rounds?
Quote from: Springer on June 04, 2004, 03:50:59 PM
How far does it carry a number before it rounds?
The round function (http://de3.php.net/manual/en/function.round.php) 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?