ID:               28975
 Comment by:       arattink at correct dot net
 Reported By:      phpbug at billix dot franken dot de
 Status:           Open
 Bug Type:         Output Control
 Operating System: Linux
 PHP Version:      Irrelevant
 New Comment:

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.


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

[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