diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Round.php b/src/PhpSpreadsheet/Calculation/MathTrig/Round.php index 0bb4ba2dc6..d2aa1c0b13 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Round.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Round.php @@ -72,7 +72,7 @@ public static function up($number, $digits): array|string|float if ($digitsPlus1 < 0) { return round($number - 0.5 * 0.1 ** $digits, $digits, PHP_ROUND_HALF_DOWN); } - $result = sprintf("%.{$digitsPlus1}f", $number - 0.5 * 0.1 ** $digits); + $result = sprintf("%.{$digitsPlus1}F", $number - 0.5 * 0.1 ** $digits); return round((float) $result, $digits, PHP_ROUND_HALF_DOWN); } @@ -80,7 +80,7 @@ public static function up($number, $digits): array|string|float if ($digitsPlus1 < 0) { return round($number + 0.5 * 0.1 ** $digits, $digits, PHP_ROUND_HALF_DOWN); } - $result = sprintf("%.{$digitsPlus1}f", $number + 0.5 * 0.1 ** $digits); + $result = sprintf("%.{$digitsPlus1}F", $number + 0.5 * 0.1 ** $digits); return round((float) $result, $digits, PHP_ROUND_HALF_DOWN); } @@ -119,7 +119,7 @@ public static function down($number, $digits): array|string|float if ($digitsPlus1 < 0) { return round($number + 0.5 * 0.1 ** $digits, $digits, PHP_ROUND_HALF_UP); } - $result = sprintf("%.{$digitsPlus1}f", $number + 0.5 * 0.1 ** $digits); + $result = sprintf("%.{$digitsPlus1}F", $number + 0.5 * 0.1 ** $digits); return round((float) $result, $digits, PHP_ROUND_HALF_UP); } @@ -128,7 +128,7 @@ public static function down($number, $digits): array|string|float return round($number - 0.5 * 0.1 ** $digits, $digits, PHP_ROUND_HALF_UP); } - $result = sprintf("%.{$digitsPlus1}f", $number - 0.5 * 0.1 ** $digits); + $result = sprintf("%.{$digitsPlus1}F", $number - 0.5 * 0.1 ** $digits); return round((float) $result, $digits, PHP_ROUND_HALF_UP); } diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Trunc.php b/src/PhpSpreadsheet/Calculation/MathTrig/Trunc.php index 34f18d5403..136f2f4a41 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Trunc.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Trunc.php @@ -52,7 +52,7 @@ public static function evaluate(array|float|string|null $value = 0, array|int|st return ($minusSign === '') ? $result : -$result; } $decimals = PHP_FLOAT_DIG - strlen((string) (int) $value); - $resultString = sprintf('%.' . $decimals . 'f', $value); + $resultString = sprintf('%.' . $decimals . 'F', $value); $regExp = '/([.]\\d{' . $digits . '})\\d+$/'; $result = $minusSign . (preg_replace($regExp, '$1', $resultString) ?? $resultString);