php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23435 number_format works badly
Submitted: 2003-05-01 04:37 UTC Modified: 2003-05-01 04:56 UTC
From: marcin at gasnace dot slonca dot net Assigned:
Status: Not a bug Package: *Math Functions
PHP Version: 4.3.1 OS: Slackware Linux 8.1 kernel2.4.20
Private report: No CVE-ID: None
 [2003-05-01 04:37 UTC] marcin at gasnace dot slonca dot net
i've got a script:

<?
echo number_format("4.705",2,'.','');
echo "<br>";
echo number_format("1.785",2,'.','');
?>

the result should be:

4.71
1.79 (because last digit is 5)

but is

4.71
1.78 <-- why?

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-05-01 04:56 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

This has to do with float rounding guidelines, not a bug in PHP.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Dec 05 11:01:23 2020 UTC