From: office at devstudio dot ro
Operating system: Windows, FreeBSD, Linux
PHP version: 5.2.9RC2
PHP Bug Type: Feature/Change Request
Bug description: Mathenatical comparison of an expression with it's result
returns false
Description:
------------
Mathenatical comparison of an expression with it's result returns false
When I try to compare 1.5 * 0.19 with it's result, 0.285, PHP returns
false, but when i display the result 1.5 * 0.19 it echoes 0.285.
Reproduce code:
---------------
<?php
// BUG!!! This expression should return TRUE, because 1.5 * 0.19 is 0.285
echo ((1.5 * 0.19) == 0.285) ? "TRUE" : "FALSE";
echo "<br />"; echo "<br />";
// Mathematical representations are the same
echo sprintf("%e", 1.5 * 0.19);
echo "<br />"; echo "<br />";
echo sprintf("%e", 0.285);
echo "<br />"; echo "<br />";
// This expression is TRUE, that's correct
echo (0.285 == 0.285) ? "TRUE" : "FALSE";
echo "<br />";
?>
Expected result:
----------------
This expression should return TRUE, because 1.5 * 0.19 is 0.285
Actual result:
--------------
Actual result is FALSE
--
Edit bug report at http://bugs.php.net/?id=47449&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=47449&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=47449&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=47449&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=47449&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=47449&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=47449&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=47449&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=47449&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=47449&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=47449&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=47449&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=47449&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=47449&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=47449&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47449&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=47449&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=47449&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=47449&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=47449&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=47449&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=47449&r=mysqlcfg