ID: 40115
Updated by: [EMAIL PROTECTED]
Reported By: jannisbreitwieser at web dot de
-Status: Open
+Status: Bogus
Bug Type: Strings related
Operating System: Linux 2.6
PHP Version: 5.2.0
New Comment:
Integers tend to overflow and this is expected.
Previous Comments:
------------------------------------------------------------------------
[2007-01-12 22:19:44] jannisbreitwieser at web dot de
Description:
------------
<?
$a = '-2147483648';
for ($a = -2147373648 ; $a > -2147483670; $a-=1000) {
$a = (string) $a;
$b = '50000';
echo $a > $b ? "$a - true\n" : "$a - false\n";
}
?>
-> The comparison should always return false but it doesnt - for some
reason some of the comparisons return true.
Reproduce code:
---------------
according to
http://www.php.net/manual/en/language.operators.comparison.php
Quote:"If you compare two numerical strings, they are compared as
integers."
This is not the case since
$a = '-2147483648';
for ($a = -2147373648 ; $a > -2147483670; $a-=1000) {
// No longer cast to string
$b = '50000';
echo $a > $b ? "$a - true\n" : "$a - false\n";
}
returns different values (which is 'false' as expected).
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=40115&edit=1