Edit report at https://bugs.php.net/bug.php?id=47418&edit=1

 ID:                 47418
 Comment by:         miguelzubiaga at ipronet dot es
 Reported by:        cu19 at gmx dot de
 Summary:            number_format misbehaving with some values
 Status:             Feedback
 Type:               Bug
 Package:            *Math Functions
 Operating System:   Win7
 PHP Version:        5.3.1
 Block user comment: N
 Private report:     N

 New Comment:

Not a number_format() problem, a simple echo also fails.
<?php echo 1.7 ?>
expected: 1.7
result: 1.6:

using Apache/2.2.11 (Win32) DAV/2 PHP/5.2.9-2

Restarting apache fixes the problem temporarily


Previous Comments:
------------------------------------------------------------------------
[2011-01-24 21:03:47] paj...@php.net

VC6 builds I suppose?

------------------------------------------------------------------------
[2011-01-24 20:47:53] pjs67123 at yahoo dot com

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.

------------------------------------------------------------------------
[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?

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


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

    https://bugs.php.net/bug.php?id=47418


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

Reply via email to