|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-06-30 17:40 UTC] 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" PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 06:00:01 2025 UTC |
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.