Bug #16036 Updated: in_array() with pow()

From: Date: Wed, 13 Mar 2002 11:23:41 +0000
Subject: Bug #16036 Updated: in_array() with pow()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-2372@lists.php.net to get a copy of this message
ID: 16036 Updated by: rasmus@php.net Reported By: goodman888@hongkong.com Status: Bogus Bug Type: *Math Functions Operating System: Solaris PHP Version: 4.1.0 New Comment: This is a variation of the commonly asked floating point number comparison question. At numbers beyond 2^31-1 pow() returns a float. Doing exact comparisons of an integer against a floating point value in any computer language is tricky because of the way floating point numbers are represented. You could make sure your precision is set the way you want and convert to a string, or apply a fuzz factor. Previous Comments: ------------------------------------------------------------------------ [2002-03-13 06:20:57] mfischer@php.net var_dump() _ONLY_ works on variables. ------------------------------------------------------------------------ [2002-03-13 06:15:21] goodman888@hongkong.com $a = pow(2,31); $b = array($a); var_dump( in_array(2147483648, $b)); $b = array(2147483648); var_dump( in_array(2147483648, $b)); // this is the result. how come there are different? bool(false) bool(true) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=16036&edit=1

« previous php.bugs (#2372) next »