leetcode——231—— Power of Two

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;
        
    }
};

你可能感兴趣的:(LeetCode,power,算法题)