Bug #54547 [Opn->Ver]: wrong equality of string numbers

From: Date: Sat, 16 Apr 2011 23:58:53 +0000
Subject: Bug #54547 [Opn->Ver]: wrong equality of string numbers
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-160214@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
 Updated by:         cataphract@php.net
 Reported by:        peter dot ritt at gmx dot net
 Summary:            wrong equality of string numbers
-Status:             Open
+Status:             Verified
 Type:               Bug
 Package:            Unknown/Other Function
 Operating System:   linux
 PHP Version:        5.3.6
 Block user comment: N
 Private report:     N



Previous Comments:
------------------------------------------------------------------------
[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


Thread (44 messages)

« previous php.bugs (#160214) next »