ID:               28633
 Updated by:       [EMAIL PROTECTED]
 Reported By:      jschmidt at thriftycmh dot net
-Status:           Open
+Status:           Assigned
-Bug Type:         Unknown/Other Function
+Bug Type:         Math related
 Operating System: Linux 2.4
 PHP Version:      4.3.7
-Assigned To:      
+Assigned To:      iliaa
 New Comment:

Ilia, recheck.. :)



Previous Comments:
------------------------------------------------------------------------

[2004-06-16 22:36:13] php at alterego dot dp dot ua

Sorry, but this actually is a bug. Kind of brain damage.

echo sprintf('%05.2f', 0.02) . "\n";
00000.02

echo sprintf('%05.2f', 2.02) . "\n";
02.02

Although the double-checked documentation is very uncertain about how
this should work, it definitely should work one of the ways, not both.

------------------------------------------------------------------------

[2004-06-04 22:26:26] jschmidt at thriftycmh dot net

Actually, I did find inconsistency (bug) with the new behavior.

echo sprintf("%06.2f",'1.00');
001.00

echo sprintf("%06.2f",'.01');
000000.01

So which is it?  Pad to 6 characters or pad to 6 on the left of the
decimal point?

------------------------------------------------------------------------

[2004-06-04 18:47:23] jschmidt at thriftycmh dot net

OK, looking at /ext/standard formatted_print.c I see what has changed. 
Before we were specifying the desired number of characters to pad to the
left of the decimal.  Now we are specifying the total desired number of
characters the output should be padded to.  So technically, we are
indeed "padding the results to the right string size".  Too bad it has
been the previous way for so long.

------------------------------------------------------------------------

[2004-06-04 17:56:29] jschmidt at thriftycmh dot net

How can this be correct behavior if it was working this way for all the
previous 4.3.X versions?  I did check the manual and I see no updates to
indicate that this is changed behavior.  In fact, quoting from the
manual:

http://www.php.net/manual/en/function.sprintf.php

"Each conversion specification consists of a percent sign (%), followed
by one or more of these elements, in order: 

An optional padding specifier that says what character will be used for
padding the results to the right string size. This may be a space
character or a 0 (zero character). The default is to pad with spaces"

So again, sprintf("%3.2f",'1.00') is no longer padding with leading
spaces as it was in previous versions.  If it is a changed behavior,
please indicate this in the documentation.

------------------------------------------------------------------------

[2004-06-04 17:21:44] [EMAIL PROTECTED]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

This is the correct behaviour. 

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/28633

-- 
Edit this bug report at http://bugs.php.net/?id=28633&edit=1

Reply via email to