diff --git a/Sources/Localization/MessageFormatter.php b/Sources/Localization/MessageFormatter.php index c307802679..3721cd4dc1 100644 --- a/Sources/Localization/MessageFormatter.php +++ b/Sources/Localization/MessageFormatter.php @@ -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); @@ -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); @@ -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);