```
class Solution
{
public:
double myPow(double x, int n)
{
bitset<32> bit(abs(n));
double result = 1;
for(int i = bit.size()-1; i >= 0; i--)
{
result*=result;
if(bit[i] == 1)
result *=x;
}
return (n >= 0)?result : 1/result;
}
};
```