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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 03:01:28 2024 UTC