php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29538 number_format and problem with 0
Submitted: 2004-08-05 17:16 UTC Modified: 2006-07-16 10:59 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: maugeri at tiscali dot it Assigned:
Status: Closed Package: Math related
PHP Version: 4.4.2, 5.1.* OS: *
Private report: No CVE-ID: None
 [2004-08-05 17:16 UTC] maugeri at tiscali dot it
Description:
------------
When i try to obtain a value withou the separator give me 
a strange result... 
 
$sfero = number_format("0.25", 2, '', ''); 
echo $sfero; 
 
it give 25 and not 025!!!!! 
 
now i must use 
 
$sfero = number_format("0.25", 2, ',', ''); 
$sfero = str_replace(",", "", $sfero); 
 
i don't know if is a bug but first,with other php version, 
the function number_format worked fine 

Reproduce code:
---------------
<?PHP
 
 for($i=1;$i<73;$i++){
 $sfero = ($i*0.25);
 $sfero = number_format($sfero, 2, '', '');
 echo $sfero."<br>";
 }
 
?>

Expected result:
----------------
000 
025 
050 
075 
100 
125 
150 
....etc 

Actual result:
--------------
 
25 
50 
75 
100 
125 
150 
....etc 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-12-14 01:29 UTC] iliaa@php.net
With what version did it work "correctly" I tested 4.3.7, 4.3.8, 4.3.9 and 4.3.10RCs and they all don't have a leading 0.
 [2005-01-27 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2006-07-16 10:59 UTC] helly@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 08:01:29 2024 UTC