php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55096 in_array returns true with 17 lenght int
Submitted: 2011-07-01 03:00 UTC Modified: 2011-07-01 03:24 UTC
From: mati at we dot ee Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.2.17 OS: linux
Private report: No CVE-ID: None
 [2011-07-01 03:00 UTC] mati at we dot ee
Description:
------------
echo in_array(9440385200600001069, array(9440385200600001036)) . '<br />';
echo in_array(9440385200600001069, array(9440385200600001036), true) . '<br />';

outputs 
1
1


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-07-01 03:09 UTC] aharvey@php.net
-Status: Open +Status: Bogus
 [2011-07-01 03:09 UTC] aharvey@php.net
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.

Integers beyond PHP_INT_MAX are silently converted to floats, and float equality 
is, as the above blurb says, interesting.
 [2011-07-01 03:24 UTC] mati at we dot ee
Ok, good to now
Thank you for quick answer.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 08 00:01:31 2024 UTC