Bug 203378

Summary: PHP *printf() %f formatting problems
Product: Red Hat Enterprise Linux 3 Reporter: Eric J. Christeson <eric.christeson>
Component: phpAssignee: Joe Orton <jorton>
Status: CLOSED WONTFIX QA Contact: David Lawrence <dkl>
Severity: high Docs Contact:
Priority: medium    
Version: 3.0   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-12-05 18:48:20 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Eric J. Christeson 2006-08-21 15:52:33 UTC
Description of problem:

php 4.3.2
printf() float formatting is incorrect.

How reproducible:
printf("|%010.2f|\n",1234567.89);
  
Actual results:
|0001234567.89|

Expected results:
|1234567.89|

Additional info:
This is fixed in php 4.3.7  The PHP changelog for 4.3.7 didn't list any apparent
fixed bugs that would correct this, but had this comment:

Fixed problems with *printf() functions and '%f' formatting. (Marcus)

Comment 1 Joe Orton 2006-12-05 18:48:20 UTC
Thanks for the report.  Unfortunately to fix this would be an interface change
which would result in output changes to sites which rely on the current
behaviour, so is not a change which could be made in a RHEL update.

In case it's not clear, the 4.3.2 behaviour was to count only the length of the
integer part towards the field width; so the workaround is to use a field width
specifier N smaller than desired where N is equal to precision + 1 (1 for the
radix).   It is appreciated that it is awkward to use such a workaround for PHP
code designed to be portable across multiple versions of PHP.