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: 2020-11-26 17:02 UTC
Votes:4
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
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: obouda at email dot cz
New email:
PHP Version: OS:

 

 [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

Pull Requests

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
 [2020-11-26 17:02 UTC] cmb@php.net
-Status: Assigned +Status: Closed
 [2020-11-26 17:02 UTC] cmb@php.net
From the 3v4l.org output, this has apparently been fixed in the
meantime.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 10:01:28 2024 UTC