Bug #54547 [PATCH]: wrong equality of string numbers
| From: | cataphract@php.net | Date: | Sun, 17 Apr 2011 03:44:04 +0000 |
| Subject: | Bug #54547 [PATCH]: wrong equality of string numbers | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-160219@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=54547&edit=1
ID: 54547
Patch added by: cataphract@php.net
Reported by: peter dot ritt at gmx dot net
Summary: wrong equality of string numbers
Status: Verified
Type: Bug
Package: Unknown/Other Function
Operating System: linux
PHP Version: 5.3.6
Assigned To: dmitry
Block user comment: N
Private report: N
New Comment:
The following patch has been added/updated:
Patch Name: bug54547-2.diff
Revision: 1303011843
URL:
http://bugs.php.net/patch-display.php?bug=54547&patch=bug54547-2.diff&revision=1303011843
Previous Comments:
------------------------------------------------------------------------
[2011-04-17 01:59:59] cataphract@php.net
The following patch has been added/updated:
Patch Name: bug54547.diff
Revision: 1302998399
URL:
http://bugs.php.net/patch-display.php?bug=54547&patch=bug54547.diff&revision=1302998399
------------------------------------------------------------------------
[2011-04-16 20:07:43] peter dot ritt at gmx dot net
Description:
------------
comparison of strings using == shows wrong results when both strings are
numbers (digits) around PHP_MAX_INT;
the same comparison using === works correctly;
tested on 64 bit systems only, affects also PHP 5.3.5
Test script:
---------------
$a = '9223372036854775807';
$b = '9223372036854775808';
if ($a == $b) {
echo "$a == $b\n";
}
else {
echo "$a != $b\n";
}
// displays 9223372036854775807 == 9223372036854775808
Expected result:
----------------
should display
9223372036854775807 != 9223372036854775808
Actual result:
--------------
displays
9223372036854775807 == 9223372036854775808
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=54547&edit=1