php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53165 Expression calculation bug
Submitted: 2010-10-26 13:05 UTC Modified: 2010-10-26 13:11 UTC
From: rt at interlogic dot com dot ua Assigned:
Status: Not a bug Package: Math related
PHP Version: 5.2.14 OS: Windows XP
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: rt at interlogic dot com dot ua
New email:
PHP Version: OS:

 

 [2010-10-26 13:05 UTC] rt at interlogic dot com dot ua
Description:
------------
It doesn't calculate expected value (220) in the given example (110 / (100 - 50) * 100).

Test script:
---------------
echo '<pre>';
echo 110 / (100 - 50) * 100;
echo "\n";
echo var_export((110 / (100 - 50) * 100) == 220);
echo "\n";
echo ceil(110 / (100 - 50) * 100);
echo "\n";
echo sprintf('%.15f', 110 / (100 - 50) * 100);
echo '</pre>';



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-10-26 13:11 UTC] derick@php.net
-Status: Open +Status: Bogus
 [2010-10-26 13:11 UTC] derick@php.net
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.

If you would like to know more about "floats" and what IEEE
754 is, read this:
http://docs.sun.com/source/806-3568/ncg_goldberg.html
 
Thank you for your interest in PHP.

.
 [2014-12-25 20:40 UTC] irker@php.net
Automatic comment from SVN on behalf of irker
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=335360
Log: Commited translation by Олег #53165
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 15:01:34 2025 UTC