Skip to content

Commit

Permalink
Merge pull request #8156 from live627/fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Sesquipedalian authored Apr 1, 2024
2 parents 55bf8b8 + 25bc690 commit 1e8f91b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Sources/Localization/MessageFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ protected static function applyNumberSkeleton(int|float|string $number, string $
// Float precision format.
if (str_starts_with($stem, '.')) {
$significant_integers = strlen(strval(intval($number + 0)));
$significant_decimals = is_int($number + 0) ? 0 : max(0, strlen(rtrim(sprintf('%.53F', abs($number + 0)), '0')) - $significant_integers - 1);
$significant_decimals = (int) strpos(strrev(strval($number)), '.');

preg_match('/\.(0*)(#*)(\*?)/', $stem, $matches);

Expand Down Expand Up @@ -679,7 +679,7 @@ protected static function applyNumberSkeleton(int|float|string $number, string $
// Significant digits format.
elseif (str_starts_with($stem, '@')) {
$significant_integers = strlen(strval(intval($number + 0)));
$significant_decimals = is_int($number + 0) ? 0 : max(0, strlen(rtrim(sprintf('%.53F', abs($number + 0)), '0')) - $significant_integers - 1);
$significant_decimals = (int) strpos(strrev(strval($number)), '.');

preg_match('/(@+)(#*)(\*?)/', $stem, $matches);

Expand Down Expand Up @@ -867,7 +867,7 @@ protected static function applyNumberSkeleton(int|float|string $number, string $

// Ensure $number is a string.
if (is_float($number)) {
$precision = max(0, strlen(rtrim(sprintf('%.53F', abs($number + 0)), '0')) - strlen(strval(intval($number + 0))) - 1);
$precision = (int) strpos(strrev(strval($number)), '.');
$number = sprintf("%{$flags}.{$precision}F", $number);
} elseif (is_int($number)) {
$number = sprintf("%{$flags}d", $number);
Expand Down

0 comments on commit 1e8f91b

Please sign in to comment.