PHP 4.0 Bug #6019: Error with equal operator when comparing certain values

From: Date: Tue, 08 Aug 2000 12:59:54 +0000
Subject: PHP 4.0 Bug #6019: Error with equal operator when comparing certain values
Groups: php.dev 
Request: Send a blank email to php-dev+get-28086@lists.php.net to get a copy of this message
From: thomas@netropolis.dk Operating system: NT4.0 PHP version: 4.0.1pl2 PHP Bug Type: Scripting Engine problem Bug description: Error with equal operator when comparing certain values When comparing certain numbers using the equals operator (==) it returns true even though numbers are not equal. It doesnt matter if number is duoble or string. It only happens when number is 16 digit. 15 & 17 digits is OK. Using strcmp() doesnt produce this error. Example: <?php $one = 9834567891230000; //double $two = 9834567891230000; //double print(($one == $two)); //returns 1 (OK) $one = 9834567891230000; //double $two = 9834567891230001; //double print(($one == $two)); //returns 1 (wrong) $one = "9834567891230000"; //string $two = "9834567891230001"; //string print(($one == $two)); //returns 1 (wrong) $one = 9834567891230000; //double $two = 9834567891230002; //double print(($one == $two)); //returns 0 (OK) $one = 1834567891230000; //double $two = 1834567891230001; //double print(($one == $two)); //returns 0 (OK) ?> I have tried under diffrent versions of php both under linux and NT4.0 with the same result. latest: 4.0.1pl1 NT4.0 precompiled downloaded from php.net Can send php.ini if you want.

« previous php.dev (#28086) next »