Open
Description
Description
The following code:
<?php
printf("%.f\n", 3.1415926535);
printf("%.0f\n", 3.1415926535);
printf("%.6f\n", 3.1415926535);
?>
Resulted in this output:
3.141593
3
3.141593
But I expected this output instead:
3
3
3.141593
because the documentation (https://www.php.net/manual/en/function.printf.php and https://www.php.net/manual/en/function.sprintf.php) says "Note: If the period is specified without an explicit value for precision, 0 is assumed."
PHP Version
PHP 8.3.6 (cli) (built: Mar 19 2025 10:08:38) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.6, Copyright (c) Zend Technologies
with Zend OPcache v8.3.6, Copyright (c), by Zend Technologies
Operating System
No response