Advertisement:

Author Topic: Poll results percentages  (Read 5361 times)

Offline Ben_S

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 11,725
  • xxx
Poll results percentages
« on: June 03, 2004, 08:39:53 AM »
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.

Offline Daniel D.

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 4,426
  • Gender: Male
Re: Poll results percentages
« Reply #1 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.

Offline Christian Land

  • Full Member
  • ***
  • Posts: 686
  • Gender: Male
  • .:: are u real? ::.
    • tagdocs.de - Deine tägliche Dosis Web
Re: Poll results percentages
« Reply #2 on: June 03, 2004, 09:02:26 AM »
Try what happens if you replace:

Code: [Select]
'percent' => round($bar, $precision),
with

Code: [Select]
'percent' => round(($option[1] * 100) / $divisor, $precision),
in Display.php

Offline Ben_S

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 11,725
  • xxx
Re: Poll results percentages
« Reply #3 on: June 03, 2004, 09:06:34 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.

Try what happens if you replace:
<>

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

Offline Ben_S

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 11,725
  • xxx
Re: Poll results percentages
« Reply #4 on: June 03, 2004, 12:31:45 PM »
Try what happens if you replace:

Code: [Select]
'percent' => round($bar, $precision),
with

Code: [Select]
'percent' => round(($option[1] * 100) / $divisor, $precision),
in Display.php

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

Offline Christian Land

  • Full Member
  • ***
  • Posts: 686
  • Gender: Male
  • .:: are u real? ::.
    • tagdocs.de - Deine tägliche Dosis Web
Re: Poll results percentages
« Reply #5 on: June 03, 2004, 01:15:06 PM »
Fine ;D

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: Poll results percentages
« Reply #6 on: June 04, 2004, 06:23:55 AM »
 ! The percentages for a poll now add up a little better.

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

-[Unknown]

Offline Skoen

  • Language Moderator
  • SMF Friend
  • Sr. Member
  • *
  • Posts: 872
  • Gender: Male
  • I'm a shoe, so don't step on me ;)
    • Radio 3 Norge
Re: Poll results percentages
« Reply #7 on: June 04, 2004, 11:33:24 AM »
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


Offline Christian Land

  • Full Member
  • ***
  • Posts: 686
  • Gender: Male
  • .:: are u real? ::.
    • tagdocs.de - Deine tägliche Dosis Web
Re: Poll results percentages
« Reply #8 on: June 04, 2004, 03:09:34 PM »
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

Offline Springer

  • Jr. Member
  • **
  • Posts: 326
  • Gender: Male
Re: Poll results percentages
« Reply #9 on: June 04, 2004, 03:50:59 PM »
How far does it carry a number before it rounds?

Offline Christian Land

  • Full Member
  • ***
  • Posts: 686
  • Gender: Male
  • .:: are u real? ::.
    • tagdocs.de - Deine tägliche Dosis Web
Re: Poll results percentages
« Reply #10 on: June 05, 2004, 02:37:16 AM »
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?