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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
33 - 28 = ?
Subscribe to this entry?

 
 [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-2024 The PHP Group
All rights reserved.
Last updated: Wed May 08 18:01:34 2024 UTC