ID:               28975
 Comment by:       christophe dot bidaux at netcourrier dot com
 Reported By:      phpbug at billix dot franken dot de
 Status:           Open
 Bug Type:         Output Control
 Operating System: Linux
 PHP Version:      Irrelevant
 New Comment:

i have the same problem between the 4.3.4 and the 4.3.8 php version, on
windows system...

i made some new tests and i think that when the value is less than 1,
in 4.3.8, the number of digits before the decimal-point in the sprintf
(6 in the example) is used as the number of digits before the
decimal-point in the returned value (000000.50), whereas in the 4.3.4
version, this value is used for the length of the entire value
(included the decimal-point).


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

[2004-07-16 10:05:13] arattink at correct dot net

Line 401/403 in ext/standard/formatted_printf.c should be 
removed.  
 
/*      if (precision > 0) { 
                width += (precision + 1);        
}*/ 
 
I'm not a PHP-developer, but 'width' passed to 
php_sprintf_appenddouble should be passed on to 
php_sprintf_appendstring unaltered. It seems that in most cases 
precision is garbled to 0 so it works most of the time.

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

[2004-06-30 17:40:38] phpbug at billix dot franken dot de

Description:
------------
A printf of float values less than 1 gives an incorrect output. It
looks like the numbers before the dot equal the width specifier...

This happens with every tested PHP version (4.3.7, 5.0.0RC3 and CVS)

With PHP 4.3.6 both outputs were wrong...

Oliver

Reproduce code:
---------------
$a = sprintf ( "%06.2f" , 0.5 );
$b = sprintf ( "%06.2f" , 1.5 );
var_dump($a);
var_dump($b);


Expected result:
----------------
string(6) "000.50"
string(6) "001.50"


Actual result:
--------------
string(9) "000000.50"
string(6) "001.50"



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


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

Reply via email to