Doc #65852 [Opn->Ver]: Wrong documentation about NAN comparison
| From: | cmb@php.net | Date: | Sat, 28 Jan 2017 16:30:00 +0000 |
| Subject: | Doc #65852 [Opn->Ver]: Wrong documentation about NAN comparison | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-14387@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65852&edit=1
ID: 65852
Updated by: cmb@php.net
Reported by: chalkerx at gmail dot com
-Summary: Wrong documentation about NAN comparison.
+Summary: Wrong documentation about NAN comparison
-Status: Open
+Status: Verified
Type: Documentation Problem
Package: Documentation problem
Operating System: Linux
PHP Version: 5.5.4
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
> I believe the wording is just not precise and "value" means
> "numeric value" in this case.
Even comparing non-numeric strings with NAN yields FALSE[1]. The
sole exception appears to be TRUE[2].
[1] <https://3v4l.org/orCLn>
[2] <https://3v4l.org/VY7oe>
Previous Comments:
------------------------------------------------------------------------
[2013-10-09 09:23:36] phpmpan at mpan dot pl
As documentation states, conversion from NaN to boolean should yield TRUE, and hence TRUE == TRUE
will be TRUE too.
I believe the wording is just not precise and "value" means "numeric value" in
this case. Of course this needs to be fixed.
------------------------------------------------------------------------
[2013-10-07 17:48:03] chalkerx at gmail dot com
Whoops, browser-saved title from the old bug.
------------------------------------------------------------------------
[2013-10-07 17:46:00] chalkerx at gmail dot com
Description:
------------
http://www.php.net/manual/en/types.comparisons.php
states:
> Some numeric operations can result in a value represented by the constant NAN. Any loose or
> strict comparisons of this value against any other value, including itself, will have a result of
> FALSE
But that is invalid, because NAN loosely equals to boolean true.
Test script:
---------------
var_dump(sqrt(-1));
var_dump(sqrt(-1) == true);
Expected result:
----------------
As per documentation, the result should be:
double(NAN)
bool(false)
The documentation should be consistent with what actually happens.
Actual result:
--------------
double(NAN)
bool(true)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65852&edit=1