Edit report at http://bugs.php.net/bug.php?id=47418&edit=1
ID: 47418
Comment by: pjs67123 at yahoo dot com
Reported by: cu19 at gmx dot de
Summary: number_format misbehaving with some values
Status: No Feedback
Type: Bug
Package: *Math Functions
Operating System: Win7
PHP Version: 5.3.1
Block user comment: N
Private report: N
New Comment:
Having the same problem on PHP 5.2.13 and Apache 2.2.14 on Windows 2003
Server.
<?php
echo 1.7;
?>
produces =>
1.6:
This happens after running Apache for about a week and then consistently
happens EVERY time. Restarting Apache fixes the problem until about a
week later. I consider this to be a serious problem that renders PHP
useless for anything beyond casual applications.
Previous Comments:
------------------------------------------------------------------------
[2010-11-30 23:23:13] carrieraglan at gmail dot com
Apache/2.2.11
PHP/5.2.10
$sql = "SELECT FIELD_1 FROM DB2_TABLE WHERE ID = ?";
$cur = odbc_prepare($db_handle, $sql);
odbc_execute($cur, array(20382));
$field_1 = odbc_result($cur, "FIELD_1");
$field_1 = trim($field_1);
print "<br>".$field_1;
print "<br>".number_format($field_1, 2, '.', '');
print "<br>".number_format($field_1, 2, '.', ',');
Expected Result:
1.90000000000000E+001
19.00
19.00
Actual Result:
1.90000000000000E+001
18.:0
18.:0
------------------------------------------------------------------------
[2010-07-17 05:53:42] adrianv at taly dot net
Code to reproduce this, where lib.php contains the my_number_format
function as described by cu19 at gmx dot de. Numbers are internally
correct, but display incorrectly.
<?php
include_once("lib.php");
echo "== Demo 1 == <BR>";
$deb = 10.50;
$crd = 1;
$tot = 0;
for ($t=1;$t<=300;$t++) {
$tot += $deb - $crd;
echo "$t $tot";
echo " >>>> ";
echo strval($tot);
echo " >>>> ";
echo sprintf('%F',$tot);
echo " >>>> ";
echo number_format($tot,2);
echo " >>>> ";
echo my_number_format($tot,2);
echo " >>>> ";
echo "<BR>";
}
?>
------------------------------------------------------------------------
[2010-03-08 03:37:01] tdietsche at comcast dot net
did you ever get my email?
------------------------------------------------------------------------
[2010-02-20 01:00:00] 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".
------------------------------------------------------------------------
[2010-02-12 23:01:50] tdietsche at comcast dot net
pajoye: I have just sent you an email with an attached zip, please reply
here or to my email to confirm that you received it, thanks.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/bug.php?id=47418
--
Edit this bug report at http://bugs.php.net/bug.php?id=47418&edit=1