Don't use floor to check if integer


This solution gets accepted but is wrong. For large cases, it doesn’t check the decimal so a and x come out equal. Ex: gives WA for 147573952589676412929.

int Solution::power(string A) {

long double a = stold(A);
if(a<2) return 0;

    long double x = floor(a);
    // this is to check that a is divisible by 2. If a is not an integer, 
    // it won't be equal to it's floor
    if(a!=1 && a!=x)
        return 0;

return 1;