Willkommen Gast. Bitte Einloggen oder Registrieren
 
Sprache wählen:
 
  Last Script Version: 20

  ÜbersichtHilfeSuchenEinloggenRegistrieren  
 
Seitenindex umschalten Seiten: 1
Thema versenden Drucken
Wrong percentages on tooltips (Gelesen: 5553 mal)
Damian
YaBB Newbies
*
Offline



Beiträge: 7
Argentina
Geschlecht: male
Wrong percentages on tooltips
24.08.13 um 10:03:44
 
Hi everyone!

When I see the stats into control panel, most of the percentages into tooltips show a different number (one minus) regarding the percentage shown on screen.
In some cases, both are equals, but the most, no...

It's another bug?

Thanks in advance for any reply.
Zum Seitenanfang
 
 
IP gespeichert
 
Damian
YaBB Newbies
*
Offline



Beiträge: 7
Argentina
Geschlecht: male
Re: Wrong percentages on tooltips
Antwort #1 - 24.08.13 um 13:22:35
 
Solved!
Changing two lines in "func_display.php" and replacing "(int)" and "(int) round()" on lines 285 and 326, both to "number_format" with 2 decimals. And now percentages are more precise!

Original lines (285 and 326):
$howmuch_1 = ( int ) ( $value / $sum_total * 100 );
echo (int) round ($howmuch_3)."%";

Replaced lines (285 and 326):
$howmuch_1 = number_format (( $value / $sum_total * 100 ),2);
echo number_format($howmuch_3, 2)."%";

Hope this changes can help to someone  Zwinkernd
Zum Seitenanfang
 
 
IP gespeichert
 
Reimar
Administrator
*****
Offline



Beiträge: 1982
Geschlecht: male
Re: Wrong percentages on tooltips
Antwort #2 - 25.08.13 um 10:08:35
 
We did it in another way:

LINE 285
$howmuch_1 = ( int ) ( $value / $sum_total * 100 );
CHANGE TO:
$howmuch_1 = ( int ) round ( $value / $sum_total * 100 );

LINE 318 can be kept like it is ...

For the textual display this is needed:

LINE 325
#echo $howmuch_1."%";
CHANGE TO:
echo $howmuch_1."%";

Delete LINE 326
echo (int) round ($howmuch_3)."%";

The fact that the var $howmuch_3 will not be used anymore, so we can delete LINE 287.
Zum Seitenanfang
« Zuletzt geändert: 25.08.13 um 15:48:19 von Holger »  
 
IP gespeichert
 
Damian
YaBB Newbies
*
Offline



Beiträge: 7
Argentina
Geschlecht: male
Re: Wrong percentages on tooltips
Antwort #3 - 25.08.13 um 18:28:10
 
Yeah, that change works too, but rounding percentages numbers always generate a little precision problem...

Some times percentages sum 99% and some other times 101%, depending on each rounding (and that's not good regarding to precision terms).

Even, with 2 decimals, precision goes from 99.99% to 100.01%... So, the best (but not recommended for most projects), is using 5 decimals.
Zum Seitenanfang
 
 
IP gespeichert
 
Seitenindex umschalten Seiten: 1
Thema versenden Drucken