Re: Test for whole number.

From: Date: Sun, 07 Apr 2002 23:16:48 +0000
Subject: Re: Test for whole number.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-91963@lists.php.net to get a copy of this message
That post was incomprehensible. Here it is revised: I'd like to condense the function below into one line. function isOneBitSet($n) { $x = log($n)/log(2); return ($x == intval($x)); } AND I don't want to do this: return (log($n)/log(2) == intval(log($n)/log(2))); So, is there a way to check if a number is whole only using the number once? Something like is_whole_number(log($n)/log(2)); Charlie > Is there a one line test for whole numbers? > > I want to condense this function down to one line: > > function isOneBitSet($n) > { > $x = log($n)/log(2); > return ($x == intval($x)); > } > > TIA, > > Charlie > >

« previous php.general (#91963) next »