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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 15 04:01:30 2024 UTC