Given an integer, write a function to determine if it is a power of two.
class Solution {
public:
bool isPowerOfTwo(int x){
double data = log10(x)/log10(2);
return (data-(int)data==0)?true:false;
}
};
Given an integer, write a function to determine if it is a power of two.
class Solution {
public:
bool isPowerOfTwo(int x){
double data = log10(x)/log10(2);
return (data-(int)data==0)?true:false;
}
};