php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28738 printf formatting bug
Submitted: 2004-06-11 05:46 UTC Modified: 2004-06-11 15:30 UTC
From: mark at islandnet dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 4.3.7 OS: FreeBSD 4.10
Private report: No CVE-ID: None
 [2004-06-11 05:46 UTC] mark at islandnet dot com
Description:
------------
Width formatting of %f values is buggy when the value is zero point something.

Reproduce code:
---------------
<?
   printf( "[%10.3f]\n", 0.5 );
   printf( "[%10.3f]\n", 1.5 );
?>


Expected result:
----------------
[     0.500]
[     1.500]

That is: same overall width for both is expected.

Actual result:
--------------
[         0.500]
[     1.500]

Note the 4 extra spaces in the first line!

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-06-11 06:07 UTC] mark at islandnet dot com
Confirmed that this bug was not in 4.3.6 or 4.3.4 (the only other versions I have handy).

Also, I have it backwards.  The first line (zero.something) is correct, it's the second line of output that is missing 4 spaces.  Previous versions of PHP output both lines with the same spacing as the second line of this example.
 [2004-06-11 15:30 UTC] iliaa@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

Dupe of bug #28633 
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Dec 01 13:00:01 2025 UTC