Doubles can be funny numbers: they don't "match" well with their decimal equivalents, so they are at best an approximation to a number, albeit a very accurate approximation.
Instead of faffing with
, take the cube root of the number, convert it to an integer, and compare that to the original:
int iscqrt(int x)
int sr = (int) cbrt(x);
return ((int) x == sr * sr * sr);