#44051 [Opn->Bgs]: Bug report for sprintf

From: Date: Tue, 05 Feb 2008 20:16:55 +0000
Subject: #44051 [Opn->Bgs]: Bug report for sprintf
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-122012@lists.php.net to get a copy of this message
 ID:               44051
 Updated by:       msaraujo@php.net
 Reported By:      andyhaslam at hotmail dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         *General Issues
 Operating System: WHM/Apache/Linux
 PHP Version:      5.2.5
 New Comment:

Hello,

It works fine here (PHP 5.2.5, PHP 5.3-snap and PHP 6).




Previous Comments:
------------------------------------------------------------------------

[2008-02-05 17:59:22] andyhaslam at hotmail dot com

Description:
------------
An interesting bug, if you do the following:

$val = 2345.35;
$val = sprintf("%01.2f", $val);
echo $val;

Output is "2.00", instead of "2345.35". The solution is to use an
intermediate variable:

$val = 2345.35;
$val2 = sprintf("%01.2f", $val);
$val = $val2;
echo $val;

Reproduce code:
---------------
$val = 2345.35;
$val = sprintf("%01.2f", $val);
echo $val;


Expected result:
----------------
2345.35

Actual result:
--------------
2.00


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=44051&edit=1


Thread (2 messages)

« previous php.bugs (#122012) next »