Bug #16036: in_array() with pow()

2002-03-13 Thread goodman888

From: [EMAIL PROTECTED]
Operating system: Solaris
PHP version:  4.1.0
PHP Bug Type: *Math Functions
Bug description:  in_array() with pow()


$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 bug report at http://bugs.php.net/?id=16036edit=1
-- 
Fixed in CVS:http://bugs.php.net/fix.php?id=16036r=fixedcvs
Fixed in release:http://bugs.php.net/fix.php?id=16036r=alreadyfixed
Need backtrace:  http://bugs.php.net/fix.php?id=16036r=needtrace
Try newer version:   http://bugs.php.net/fix.php?id=16036r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=16036r=support
Expected behavior:   http://bugs.php.net/fix.php?id=16036r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=16036r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=16036r=submittedtwice




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

2002-03-13 Thread goodman888

 ID:   16036
 Updated by:   [EMAIL PROTECTED]
 Reported By:  [EMAIL PROTECTED]
 Status:   Bogus
 Bug Type: *Math Functions
 Operating System: Solaris
 PHP Version:  4.1.0
 New Comment:

Can anyone give me a workable version?

I've tried even to convert all numbers into integers, floats or
whatever. It still does not work.


Previous Comments:


[2002-03-13 06:23:40] [EMAIL PROTECTED]

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.



[2002-03-13 06:20:57] [EMAIL PROTECTED]

var_dump() _ONLY_ works on variables.



[2002-03-13 06:15:21] [EMAIL PROTECTED]


$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=16036edit=1