Re: Perfect Squares

From: Date: Tue, 25 May 2004 23:05:20 +0000
Subject: Re: Perfect Squares
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-186962@lists.php.net to get a copy of this message
Try taking the square root of the variable $sqrt = sqrt($var); then compare the number of decimal places. if (strlen(strstr($sqrt,".")) <= strlen(strstr($var,"."))) { // perfect } Just guessing of course. On 5/25/2004 5:06 PM, Stephen Craton wrote:
I'm in a bit of a pickle. I need to find out if a variable is a perfect square or not, and this needs to test for decimal numbers as well, such as 2.25. The thing is, the only function I've found in PHP is gmp_perfect_square() which isn't supported on my web server, and I don't know how to compile the GMP code into PHP on my windows box. So, how exactly would you go about finding out if something is a perfect square or not? Thanks, Stephen Craton http://www.melchior.us


« previous php.general (#186962) next »