From: php at arantius dot com Operating system: Windows XP PHP version: 4.3.9 PHP Bug Type: Output Control Bug description: printf + zero fill + negative number = extra null character on windows xp
Description: ------------ When using printf, zero fill, floats, and negative numbers, PHP 4.3.9 on Windows XP Pro SP1 generates null characters at the end of the number that should not be there. Passing a negative number, i.e. -1, into the format string "%0.2f" will give an invalid result, i.e. "-1.00[NULL]" where [NULL] is the 0th byte. Reproduce code: --------------- <? printf("%0.2f<br />", 1.51555); //ok printf("%0.2f<br />", -1.51555); //broken printf("%0.2f<br />", -1); //broken printf("%.2f<br />", -1.5); //ok printf("%.2f<br />", -1.51555); //ok printf("%0.2f<br />", 1.51555); //ok ?> Expected result: ---------------- I expect "-1.00" or appropriately rounded values with no trailing null bytes. Actual result: -------------- Cannot paste output, it is truncated at the first null byte. -- Edit bug report at http://bugs.php.net/?id=30764&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=30764&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30764&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30764&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=30764&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=30764&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=30764&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=30764&r=needscript Try newer version: http://bugs.php.net/fix.php?id=30764&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=30764&r=support Expected behavior: http://bugs.php.net/fix.php?id=30764&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=30764&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=30764&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=30764&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=30764&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=30764&r=dst IIS Stability: http://bugs.php.net/fix.php?id=30764&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=30764&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=30764&r=float MySQL Configuration Error: http://bugs.php.net/fix.php?id=30764&r=mysqlcfg