Skip to content

Commit

Permalink
Fix issue with prepending zero in percentage -1.0<n<-0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasruunu committed Feb 27, 2024
1 parent dc84a51 commit 5173716
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/PhpSpreadsheet/Style/NumberFormat/PercentageFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class PercentageFormatter extends BaseFormatter
/** @param float|int $value */
public static function format($value, string $format): string
{
if ($format === NumberFormat::FORMAT_PERCENTAGE) {
return round((100 * $value), 0) . '%';
if (NumberFormat::FORMAT_PERCENTAGE === $format) {
return round((100 * $value)) . '%';
}

$value *= 100;
Expand All @@ -20,7 +20,7 @@ public static function format($value, string $format): string
$vDecimalCount = strlen(rtrim($vDecimals, '0'));

$format = str_replace('%', '%%', $format);
$wholePartSize = strlen((string) floor($value));
$wholePartSize = strlen((string) floor(abs($value)));
$decimalPartSize = 0;
$placeHolders = '';
// Number of decimals
Expand Down

0 comments on commit 5173716

Please sign in to comment.