Bug #68330 [NEW]: Problem with range function and float
| From: | gcrispyn at assessfirst dot com | Date: | Thu, 30 Oct 2014 15:44:06 +0000 |
| Subject: | Bug #68330 [NEW]: Problem with range function and float | ||
| Groups: | php.standards | ||
| Request: | Send a blank email to standards-+get-537@lists.php.net to get a copy of this message | ||
From: gcrispyn at assessfirst dot com
Operating system: Linux
PHP version: 5.5.18
Package: PHP Language Specification
Bug Type: Bug
Bug description:Problem with range function and float
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 bug report at https://bugs.php.net/bug.php?id=68330&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=68330&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=68330&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=68330&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=68330&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=68330&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=68330&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=68330&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=68330&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=68330&r=support
Expected behavior: https://bugs.php.net/fix.php?id=68330&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=68330&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=68330&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=68330&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=68330&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=68330&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=68330&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=68330&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=68330&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=68330&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=68330&r=mysqlcfg