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
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: marcin at gasnace dot slonca dot net
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 23:01:28 2024 UTC