#24030 [Opn->Csd]: sprintf with negative floating point type leaves null in string

From: Date: Thu, 05 Jun 2003 05:56:01 +0000
Subject: #24030 [Opn->Csd]: sprintf with negative floating point type leaves null in string
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-41227@lists.php.net to get a copy of this message
ID: 24030 Updated by: sniper@php.net Reported By: prgallier at yahoo dot com -Status: Open +Status: Closed Bug Type: Strings related Operating System: Linux 2.4.20 PHP Version: 4.3.2 New Comment: Already fixed in CVS. Previous Comments: ------------------------------------------------------------------------ [2003-06-05 00:39:08] prgallier at yahoo dot com Using sprintf with a floating point value for a negative number leaves a null character in the string, such as: $num = sprintf("%0.1f", -12.5); $num will contain the following characters within the actual string when printing out: 0x45 0x31 0x32 0x2E 0x35 0x00 This does not occur with non-negative numbers. Try the following for realtime example: <?php $num = sprintf("%0.1f", 12.5); echo "Positive Num: $num<br>\n"; $num = sprintf("%0.1f", -12.5); echo "Negative Num: $num<br>\n"; ?> This is apparently an old bug that's been reintroduced in version 4.3.2. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=24030&edit=1

« previous php.bugs (#41227) next »