Checking if sqrt() result is an integer
Moderator: General Moderators
-
braveryonions
- Forum Newbie
- Posts: 14
- Joined: Wed Feb 11, 2009 3:31 pm
Checking if sqrt() result is an integer
In a script I am working on, I need to check if the output of sqrt() is an integer. I thought this would work with is_int(), but it is always returning false. var_dump() reveals the problem: sqrt() is always returning a float number, even if it's actually an integer. This causes is_int() to return false. How can I check if these float variables are integers?
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
Re: Checking if sqrt() result is an integer
if (floor($value) == $value)
-
braveryonions
- Forum Newbie
- Posts: 14
- Joined: Wed Feb 11, 2009 3:31 pm
Re: Checking if sqrt() result is an integer
I can't believe I didn't think of that! Thank you very much!