php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71032 Comparison of float NAN returns true
Submitted: 2015-12-04 21:20 UTC Modified: 2017-10-24 05:20 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:0 (0.0%)
From: obouda at email dot cz Assigned: laruence (profile)
Status: Assigned Package: Variables related
PHP Version: 7.0.0 OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2015-12-04 21:20 UTC] obouda at email dot cz
Description:
------------
Comparison of the float NAN value to any other value is supposed to return false - as the docs of the float type says.

In PHP 5.4 to 5.6 the result is false, as expected.

In PHP 7.0, the comparison returns true.

Reproduced on Windows 7 (64bit) as well as at https://3v4l.org/GkqZZ

Test script:
---------------
<?php
var_dump(NAN < 1.0);

Expected result:
----------------
bool(false)

Actual result:
--------------
bool(true)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-12-05 01:44 UTC] requinix@php.net
-Status: Open +Status: Verified -Package: Unknown/Other Function +Package: Variables related -Operating System: Windows +Operating System:
 [2015-12-05 02:34 UTC] laruence@php.net
that is because fast_is_smaller_* behaviors differently on IS_DOULBE IS_DOUBLE pair from compare_function.

actually, PHP-5.6 has the same issue if opcache is enabled
 [2015-12-05 02:46 UTC] laruence@php.net
-Assigned To: +Assigned To: laruence
 [2015-12-05 03:01 UTC] laruence@php.net
actually, it's not only compare_function, but also fast_is_smaller doesn't take care NAN well.

https://3v4l.org/efjgU
 [2017-10-24 05:20 UTC] kalle@php.net
-Status: Verified +Status: Assigned
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Mon Jun 25 08:01:50 2018 UTC