|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-08-21 03:45 UTC] craesh at craesh dot 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" ?> PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 22 09:00:01 2025 UTC |
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! Sacheri 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)