From:             prgallier at yahoo dot com
Operating system: Linux 2.4.20
PHP version:      4.3.2
PHP Bug Type:     Strings related
Bug description:  sprintf with negative floating point type leaves null in string

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 bug report at http://bugs.php.net/?id=24030&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=24030&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=24030&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=24030&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=24030&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=24030&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=24030&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=24030&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=24030&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=24030&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=24030&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24030&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=24030&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=24030&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=24030&r=gnused

Reply via email to