When a percentage was equal to 100 %, makePercentPretty
determined it should have zero decimal places, and the
resulting string "100" had "trailing 0's" removed, resulting
in a completely wrong "1".
We might either check if the number contains the decimal dot
prior to trimming, or spare the hassle for the special case
completely.
Change-Id: I15ac5caa275d72909adba27b6b88824a830bd574
if ( $decimal == 0 ) {
return '0';
}
+ if ( $decimal >= 100 ) {
+ return '100';
+ }
$percent = sprintf( "%." . max( 0, 2 - floor( log10( $decimal ) ) ) . "f", $decimal );
// Then remove any trailing 0's
return preg_replace( '/\.?0*$/', '', $percent );