#45712 [Asn->Csd]: $something == NaN returns true with 5.3, false with 5.2.*
| From: | tony2001@php.net | Date: | Thu, 07 Aug 2008 08:36:34 +0000 |
| Subject: | #45712 [Asn->Csd]: $something == NaN returns true with 5.3, false with 5.2.* | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-127711@lists.php.net to get a copy of this message | ||
ID: 45712
Updated by: tony2001@php.net
Reported By: for-bugs at hnw dot jp
-Status: Assigned
+Status: Closed
Bug Type: Variables related
Operating System: *
PHP Version: 5.2CVS, 5.3CVS, 6CVS (2008-08-05)
Assigned To: tony2001
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2008-08-07 07:37:04] tony2001@php.net
I'm testing a patch for it.
------------------------------------------------------------------------
[2008-08-05 12:52:06] for-bugs at hnw dot jp
NaN is not exact number. So, NaN should not equals itself. Additionaly,
NaN == NaN is false in C. You can see behavior of C as follows.
$ cat nan.c
int main() {double d;d=(-1e300*1e300)/(1e300*1e300);if (d==d) return 1;
else return 2;}
$ gcc nan.c; ./a.out; echo $?
2
$
------------------------------------------------------------------------
[2008-08-05 12:33:17] jani@php.net
That $nan == $nan should be true. (like it is with 5.3)
------------------------------------------------------------------------
[2008-08-05 02:39:58] for-bugs at hnw dot jp
Description:
------------
There is == operator's problem dealing with NaN(Not a Number) in PHP
5.3.0alpha1. This behavior is different with PHP 5.0.0-5.2.6, so this is
compatibility problem.
Reproduce code:
---------------
<?php
$nan = (-1e300*1e300)/(1e300*1e300); // float(NAN)
var_dump($nan=='');
var_dump($nan==0.5);
var_dump($nan==50);
var_dump($nan=='500');
var_dump($nan=='abc');
var_dump($nan==$nan);
Expected result:
----------------
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
Actual result:
--------------
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=45712&edit=1