Edit report at https://bugs.php.net/bug.php?id=47418&edit=1
ID: 47418 Updated by: [email protected] Reported by: cu19 at gmx dot de Summary: number_format misbehaving with some values -Status: Feedback +Status: No Feedback Type: Bug Package: *Math Functions Operating System: Win7 PHP Version: 5.3.1 New Comment: No feedback was provided. The bug is being suspended because we assume that you are no longer experiencing the problem. If this is not the case and you are able to provide the information that was requested earlier, please do so and change the status of the bug back to "Open". Thank you. Previous Comments: ------------------------------------------------------------------------ [2012-03-28 08:20:22] miguelzubiaga at ipronet dot es 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 ------------------------------------------------------------------------ [2011-01-24 21:03:47] [email protected] 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>"; } ?> ------------------------------------------------------------------------ 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
