Bug #53165 [Opn->Bgs]: Expression calculation bug
| From: | derick@php.net | Date: | Tue, 26 Oct 2010 11:11:15 +0000 |
| Subject: | Bug #53165 [Opn->Bgs]: Expression calculation bug | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-155528@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=53165&edit=1
ID: 53165
Updated by: derick@php.net
Reported by: rt at interlogic dot com dot ua
Summary: Expression calculation bug
-Status: Open
+Status: Bogus
Type: Bug
Package: Math related
Operating System: Windows XP
PHP Version: 5.2.14
Block user comment: N
New Comment:
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.
.
Previous Comments:
------------------------------------------------------------------------
[2010-10-26 13:05:09] 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>';
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=53165&edit=1