#19012 [Com]: is_integer doesn't return true
| From: | msopacua at idg dot nl | Date: | Wed, 21 Aug 2002 09:22:23 +0000 |
| Subject: | #19012 [Com]: is_integer doesn't return true | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-17425@lists.php.net to get a copy of this message | ||
ID: 19012
Comment by: msopacua@idg.nl
Reported By: craesh@craesh.net
Status: Bogus
Bug Type: Variables related
Operating System: Linux
PHP Version: 4.2.2
New Comment:
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
Previous Comments:
------------------------------------------------------------------------
[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