|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30048 round() and number_format() calculates wrong
Submitted: 2004-09-10 10:48 UTC Modified: 2005-09-22 21:38 UTC
From: joerg dot klein at ifsam dot lu Assigned:
Status: Not a bug Package: Math related
PHP Version: 5.0.0 OS: win2000
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.
Block user comment
Status: Assign to:
Bug Type:
From: joerg dot klein at ifsam dot lu
New email:
PHP Version: OS:


 [2004-09-10 10:48 UTC] joerg dot klein at ifsam dot lu
I use a fomular as the first paramter and the result is wrong. 
When brackets were set, the result is correct, but this makes no sense to me.

Reproduce code:
echo round(0.35*90/100);
echo number_format(0.35*90/100, 2, ".", "");

to get the correct result I should use the following syntax:
echo round(0.35* (90/100) )
echo number_format(0.35* (90/100) , 2, ".", "");

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-09-10 11:09 UTC]
Floating point values have a limited precision. Hence a value might 
not have the same string representation after any processing. That also
includes writing a floating point value in your script and directly 
printing it without any mathematical operations.
Thank you for your interest in PHP.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jul 17 20:01:29 2024 UTC