|  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: 2020-11-26 17:02 UTC
Avg. Score:4.0 ± 1.7
Reproduced:3 of 4 (75.0%)
Same Version:3 (100.0%)
Same OS:1 (33.3%)
From: obouda at email dot cz Assigned: laruence (profile)
Status: Closed Package: Variables related
PHP Version: 7.0.0 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
46 - 34 = ?
Subscribe to this entry?

 [2015-12-04 21:20 UTC] obouda at email dot cz
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

Test script:
var_dump(NAN < 1.0);

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-12-05 01:44 UTC]
-Status: Open +Status: Verified -Package: Unknown/Other Function +Package: Variables related -Operating System: Windows +Operating System:
 [2015-12-05 02:34 UTC]
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]
-Assigned To: +Assigned To: laruence
 [2015-12-05 03:01 UTC]
actually, it's not only compare_function, but also fast_is_smaller doesn't take care NAN well.
 [2017-10-24 05:20 UTC]
-Status: Verified +Status: Assigned
 [2020-11-26 17:02 UTC]
-Status: Assigned +Status: Closed
 [2020-11-26 17:02 UTC]
From the output, this has apparently been fixed in the
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Oct 28 12:03:36 2021 UTC