I would like to ask about sqrt() function in library in c++, I have an integer number and I want to know if there is an integer-square root fo this number...like 16 --> 4, and if not return -1 here is the function:
long long SQRT(Long long x)
{
long long i;
for (i = 0; i <= x / 2; i++)
if (i * i == x)
return i;
return -1;
}
but it takes much more time than sqrt()
...can any one explain me that...thanks in advance