Bug #67501 [NEW]: strange operation of comparison of same value

From: Date: Mon, 23 Jun 2014 11:15:03 +0000
Subject: Bug #67501 [NEW]: strange operation of comparison of same value
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-186299@lists.php.net to get a copy of this message
From: blazexerit at yahoo dot co dot jp Operating system: Linux PHP version: 5.5.13 Package: *General Issues Bug Type: Bug Bug description:strange operation of comparison of same value Description: ------------ after Test script php > var_dump($now,$next); int(1060) double(1060) php > if($now == $next) echo 1,PHP_EOL; else echo 0,PHP_EOL; 0 but, php > if((int)1060 == (double)1060) echo 1,PHP_EOL; else echo 0,PHP_EOL; 1 Test script: --------------- $r = 1060; $now = 0; $next = 0; $per = $r/50; $i=0; while($i!=$r){ $now++; while($now >= $next){ $next += $per; } $i++; } var_dump($now,$next); if($now == $next) echo 1,PHP_EOL; else echo 0,PHP_EOL; Expected result: ---------------- $now is 1060. $next is 1060. So, "if($now==$next)" will return true. Actual result: -------------- "if($now==$next)" returns false. -- Edit bug report at https://bugs.php.net/bug.php?id=67501&edit=1 --

« previous php.bugs (#186299) next »