The problem here is in your definition of "whole." You read it as "a value without non-zero fractional significant digits", whereas in is_int it simply refers to a data type, that is, literally everything with an int type.
That is, a floating point value of 10.0 is still a floating point value, although its mathematical value is equal to the value of the integer 10 .
The result of sqrt never an integer; however, you can check if any nonzero fractional significant digits are floating point values ββby comparing them to the one in which you deliberately took everything away.
Naive implementation:
$sqrt = sqrt(100); if ($sqrt == (int)$sqrt) {
However, of course, you should never compare anything against a floating point value with == ; use your favorite floating point equality mechanism to perform this test.
Update
In fact, I believe that the only values ββfor which this comparison could potentially fail are fractional, in which case the test should still fail. Therefore == may be enough.
Lightness races in orbit
source share