#37403 [Opn->Bgs]: Wrong key returned in array_search
| From: | derick@php.net | Date: | Thu, 11 May 2006 06:50:10 +0000 |
| Subject: | #37403 [Opn->Bgs]: Wrong key returned in array_search | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-96943@lists.php.net to get a copy of this message | ||
ID: 37403
Updated by: derick@php.net
Reported By: jonataswalker at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Linux 2.6.13
PHP Version: 5.1.4
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://docs.sun.com/source/806-3568/ncg_goldberg.html
Thank you for your interest in PHP.
.
Previous Comments:
------------------------------------------------------------------------
[2006-05-11 04:02:33] jonataswalker at gmail dot com
Description:
------------
Hi there,
I'd like some help. I've searched and found a similar question but no
answer was given, so I need to ask same thing.
How can this be possible?
Reproduce code:
---------------
$array =
array(3453453453453453453445345345,345345345345345346452,12345);
$key = array_search(345345345345345340300,$array,true);
if ($key === false) print "false";
else print var_dump($key);
Expected result:
----------------
false
Actual result:
--------------
int(1). Even changing last 4 digits in needle, I always get int(1).
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=37403&edit=1