to chk if perfect square

i need to check if a number is a perfect square or not.its a big number
so i take that number in long long or double but unfortunately both methods giving wrong answer.
because sqrt function takes only double as input;
while '%' can't operate on double operand
please help;

you can do this by checking if the square root of that number is an integer
eg:
1
2
3
4
double d_sqrt = sqrt( NUMBER );
int i_sqrt = d_sqrt;
if ( d_sqrt == i_sqrt )
    // Your number is a perfect square 

If you prefer using the % operator, notice that it is supported only by integral types and that long long is not yet a standard type
Topic archived. No new replies allowed.