#19012 [Bgs]: is_integer doesn't return true

From: Date: Wed, 21 Aug 2002 09:26:14 +0000
Subject: #19012 [Bgs]: is_integer doesn't return true
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-17426@lists.php.net to get a copy of this message
ID: 19012 Updated by: cynic@php.net Reported By: craesh@craesh.net Status: Bogus Bug Type: Variables related Operating System: Linux PHP Version: 4.2.2 New Comment: i don't see what makes you so sure about is_integer() bugginess. nothing in what you posted supports your claim. if ($i % 8 == 0) is *not* equivalent to the is_integer() test, because it actually *ignores* the type of the result of the modulo expression. besides, i can't reproduce it either: script: echo PHP_VERSION, "\n"; var_dump(is_integer(8/(400/50))); output: 4.2.2 bool(true) Previous Comments: ------------------------------------------------------------------------ [2002-08-21 05:22:23] msopacua@idg.nl It's still phpmychat's error - or a fixed bug in 4.1.2. Return type of floor is float - not integer: gettype(floor(400/"50")); Consistent with: http://www.php.net/float ------------------------------------------------------------------------ [2002-08-21 04:37:10] craesh@craesh.net Hi! I still think is_integer() is buggy, I've this code-extract wich worked fine with PHP 4.1.2 and doesn't work with 4.2.2 $MaxWidth = "50"; // ... $PerLines = floor(400/$MaxWidth); //... while( ... ) { // ... if (is_integer($i/$PerLines) ) { //... } } It's actualy an extract from the phpmychat (don't know wich version, I think one of the latest), on PHP 4.1.2 the if-clause matches every 8 iterations, on PHP 4.2.2 never. If you exchance the if-clause with this: if ( $i % 8 == 0 ) { you get a match every 8 iterations, so is_integer has to be buggy. Thanks! Sacher ------------------------------------------------------------------------ [2002-08-21 04:11:59] cynic@php.net 2.0 is not an integer. is_integer(2.0) returns false, which is '' in string contexts. ------------------------------------------------------------------------ [2002-08-21 03:45:22] craesh@craesh.net It's just that is_integer( $a_double_value ) doesn't seem to return true nor anything else if the double matches a integer value. Just try this script: <?php $a = 2.0; $b = 1.0; echo is_integer( $a/$b ); echo is_integer( 2.0 ); // Doesn't output anything echo is_integer( 2 ); echo is_integer( 2/1 ); echo is_int( 2 ); // These 3 test do output "1" ?> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=19012&edit=1

« previous php.bugs (#17426) next »