Doc #65852 [Ver->Csd]: Wrong documentation about NAN comparison
| From: | cmb@php.net | Date: | Sat, 28 Jan 2017 16:33:22 +0000 |
| Subject: | Doc #65852 [Ver->Csd]: Wrong documentation about NAN comparison | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-14388@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
-Status: Verified
+Status: Closed
Type: Documentation Problem
Package: Documentation problem
Operating System: Linux
PHP Version: 5.5.4
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation better.
Previous Comments:
------------------------------------------------------------------------
[2017-01-28 16:32:56] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&revision=341793
Log: Fix #65852: Wrong documentation about NAN comparison
------------------------------------------------------------------------
[2017-01-28 16:29:56] cmb@php.net
> 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>
------------------------------------------------------------------------
[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