#25936 [Opn->Bgs]: comparing 2 float variables with same value result false
| From: | elmicha@php.net | Date: | Tue, 21 Oct 2003 15:57:40 +0000 |
| Subject: | #25936 [Opn->Bgs]: comparing 2 float variables with same value result false | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-49291@lists.php.net to get a copy of this message | ||
ID: 25936
Updated by: elmicha@php.net
Reported By: sebastian dot sieburg at partyleader dot de
-Status: Open
+Status: Bogus
Bug Type: Variables related
Operating System: Linux, BSD, etc. ..
PHP Version: Irrelevant
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
See <http://de.php.net/manual/de/language.types.float.php>.
Previous Comments:
------------------------------------------------------------------------
[2003-10-21 11:34:30] sebastian dot sieburg at partyleader dot de
Description:
------------
set a var using round, the other via value ... compare the vars .. same
values but comparision returns false .. tried in php 4.3.1, 5.0.0-dev
and 4.1.2 .. same problem in all versions ..
Reproduce code:
---------------
<?php
$val = 1.11;
echo "\$val: "; var_dump ($val);
$p1 = $val * 100;
$p2 = round ($val * 100);
$p1 = (float)$p1;
$p2 = (float)$p2;
if ($p1 == $p2)
echo "$p1 == $p2";
else
echo "$p1 != $p2";
echo "\n";
echo "\$p1: "; var_dump ($p1);
echo "\$p2: "; var_dump ($p2);
?>
Expected result:
----------------
$val: float(1.11)
111 == 111
$p1: float(111)
$p2: float(111)
Actual result:
--------------
$val: float(1.11)
111 != 111
$p1: float(111)
$p2: float(111)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=25936&edit=1