Bug #66166 [Opn->Nab]: in_array() è¿åçå¤æç»ææ¯é误ç
| From: | bwoebi@php.net | Date: | Mon, 25 Nov 2013 12:26:04 +0000 |
| Subject: | Bug #66166 [Opn->Nab]: in_array() è¿åçå¤æç»ææ¯é误ç | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-182915@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=66166&edit=1
ID: 66166
Updated by: bwoebi@php.net
Reported by: 290315384 at qq dot com
Summary: in_array() è¿åçå¤æç»ææ¯é误ç
-Status: Open
+Status: Not a bug
Type: Bug
Package: *General Issues
Operating System: win7
PHP Version: master-Git-2013-11-25 (Git)
Block user comment: N
Private report: N
New Comment:
Floating point values have a limited precision. Hence a value might
not have the same string representation after any processing. That also
includes writing a floating point value in your script and directly
printing it without any mathematical operations.
If you would like to know more about "floats" and what IEEE
754 is, read this:
http://www.floating-point-gui.de/
Thank you for your interest in PHP.
Numeric strings are, if the third parameter ($strict) is not set, compared numerically.
Too big integers are already casted to float before they are passed to the function in_array.
But due to floating point imprecision, it has the same binary representation, so it's true even
with strict parameter.
Previous Comments:
------------------------------------------------------------------------
[2013-11-25 11:52:13] 290315384 at qq dot com
Description:
------------
---
From manual page: http://www.php.net/function.in-array
---
PHP version:5.3.13
Package affected:
Test script:
---------------
<?php
$arr = array ('22727824922116425');
var_dump(in_array('22727824922116421',$arr)); //true
var_dump(in_array('22727824922116422',$arr)); //true
//......
var_dump(in_array('22727824922116426',$arr)); //true
var_dump(in_array('22727824922116427',$arr)); //true
var_dump(in_array('22727824922116422',$arr,true)); //false
$arr = array (22727824922116425);
var_dump(in_array(22727824922116422,$arr)); //true
var_dump(in_array(22727824922116422,$arr,true));//true
?>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66166&edit=1