Bug 203378 - PHP *printf() %f formatting problems
Summary: PHP *printf() %f formatting problems
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: php
Version: 3.0
Hardware: All
OS: Linux
medium
high
Target Milestone: ---
Assignee: Joe Orton
QA Contact: David Lawrence
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2006-08-21 15:52 UTC by Eric J. Christeson
Modified: 2007-11-30 22:07 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2006-12-05 18:48:20 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

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.


Note You need to log in before you can comment on or make changes to this bug.