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
 [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: Sat Dec 21 16:01:28 2024 UTC