php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74974 NAN Comparison
Submitted: 2017-07-22 22:51 UTC Modified: 2017-07-23 13:00 UTC
From: webmaster at icecub dot nl Assigned: pollita (profile)
Status: Closed Package: Math related
PHP Version: 7.2Git-2017-07-22 (Git) OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: webmaster at icecub dot nl
New email:
PHP Version: OS:

 

 [2017-07-22 22:51 UTC] webmaster at icecub dot nl
Description:
------------
NAN Comparison is giving unexpected results since PHP version 5.4.0 up till the latest 7.2.0beta1. I know NAN comparison should be avoided. It's just a bug report.

Test script:
---------------
$nan = NAN;

if(0 < NAN){ echo 'TRUE'; } else { echo 'FALSE'; }
echo "\n";
if(0 < $nan){ echo 'TRUE'; } else { echo 'FALSE'; }

Expected result:
----------------
Expected output in example script:
TRUE
TRUE

Actual result:
--------------
Output versions 7.0.0 - 7.2.0beta1:
TRUE
FALSE

Output versions 5.4.0 - 5.6.30, hhvm-3.10.1 - 3.19.0:
FALSE
FALSE

Output versions 4.3.6 - 5.3.29:
TRUE
TRUE

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-07-22 23:09 UTC] webmaster at icecub dot nl
The expected output should be:
FALSE
FALSE

According to the docs: Any loose or strict comparisons of this value against any other value, including itself, but except TRUE, will have a result of FALSE.
 [2017-07-23 12:57 UTC] mail at pmmaga dot net
This has been fixed by commit https://github.com/php/php-src/commit/c562d44321ea69612fbe3f7460055e9ed4340baa
 [2017-07-23 13:00 UTC] kalle@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: pollita
 [2017-07-23 13:00 UTC] kalle@php.net
Fixed by Sara
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 05:01:32 2024 UTC