diff -u b/core/lib/Drupal/Component/Utility/Number.php b/core/lib/Drupal/Component/Utility/Number.php --- b/core/lib/Drupal/Component/Utility/Number.php +++ b/core/lib/Drupal/Component/Utility/Number.php @@ -18,7 +18,8 @@ * @param $number int|float|string * The value to normalize. If this is a string, it must be formatted as an * integer or a float. Floats with a higher number of significant decimals - * than 14 will lose the additional precision as PHP does not guarantee. + * than precision value from the PHP runtime configuration [default: 14] + * will lose the additional precision as PHP does not guarantee. * * @return string * The normalized numeric string. @@ -28,12 +29,12 @@ if (is_float($number)) { // If the float has less significant decimals than the number we can // guarantee, convert it to a string directly. - if (preg_match(sprintf('/^\d+\.\d{1,%d}$/', 14), (string) $number)) { + if (preg_match(sprintf('/^\d+\.\d{1,%d}$/', ini_get('precision')), (string) $number)) { return (string) $number; } // For floats with more significant decimals than the number we can // guarantee, discard the unguaranteed ones. - return rtrim(number_format($number, 14, '.', ''), '0'); + return rtrim(number_format($number, ini_get('precision'), '.', ''), '0'); } return (string) $number; }