|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-02-19 11:25 UTC] derick@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 02:00:01 2025 UTC |
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