This solution works for float but not double.why?


#1

int Solution::isPower(int A) {
float l;
if(A==1){
return 1;
}
for(int i=2;i<=sqrt(A);i++){
l=(log(A)/log(i));

    if(l==int(l)){
        return 1;
    }
}
return 0;

}