|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-01-19 03:25 UTC] sniper@php.net
[2005-01-28 01:00 UTC] php-bugs at lists dot php dot net
[2008-08-20 07:32 UTC] babu at ransysbios dot com
[2008-08-20 08:00 UTC] pajoye@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 26 07:00:01 2025 UTC |
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.