php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21801 number_format do not round correctly
Submitted: 2003-01-21 12:38 UTC Modified: 2005-09-22 21:42 UTC
From: supad at noos dot fr Assigned:
Status: Closed Package: Math related
PHP Version: 4.2.2 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: supad at noos dot fr
New email:
PHP Version: OS:

 

 [2003-01-21 12:38 UTC] supad at noos dot fr
<?
echo number_format(0.49)."<br>";
echo number_format(0.50)."<br>";
echo number_format(0.51)."<br><br>";

echo round(0.49)."<br>";
echo round(0.50)."<br>";
echo round(0.51)."<br>";
?>

returns

0
0
1

0
1
1

number_format do not round correctly while round does.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-21 14:10 UTC] iliaa@php.net
In 4.3 both round() and number_format() round 0.5 to 1. Keep in mind that this may also depend on your libc, which is what doing the rounding.
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Dec 06 04:05:54 2022 UTC