Bug #68330 [Opn->Nab]: Problem with range function and float

[email protected]
Newsgroups php.standards
Message-ID <[email protected]>
Edit report at https://bugs.php.net/bug.php?id=68330&edit=1

 ID:                 68330
 Updated by:         [email protected]
 Reported by:        gcrispyn at assessfirst dot com
 Summary:            Problem with range function and float
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            PHP Language Specification
 Operating System:   Linux
 PHP Version:        5.5.18
 Block user comment: N
 Private report:     N

 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Floating point values are known to be inaccurate. The manual states you shouldn't try to check for equality.


Previous Comments:
------------------------------------------------------------------------
[2014-10-30 15:44:04] gcrispyn at assessfirst dot com

Description:
------------
When you want to know if (float)7.8 value is in the range between 7 and 10 with a step of 0.1, the result is false. But, when you use the same function with a range between 6 and 10, the result is true.

Expected result:
----------------
var_dump(in_array(7.8, range(6, 10, .1))); --> true
var_dump(in_array(7.8, range(7, 10, .1))); --> true

Actual result:
--------------
var_dump(in_array(7.8, range(6, 10, .1))); --> true
var_dump(in_array(7.8, range(7, 10, .1))); --> false


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=68330&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.