class Solution {
public:
double pow(double x, int n) {
double res=1;
if(n<0){
x=1/x;
n=n;
}
while(n>0){
if(n&1==1){
res=res*x;
}
x*=x;
n=n>>1;
}
return res;
}
};
My answer bit operation O(1)

@liulin2728 said in My answer bit operation O(1):
if n is equal to 2147483648, x is not 1,your solution has some problem.
because if n == 2147483648,"n" is also equal to 2147483648.well, for 32 bit integer n , 2147483648, this minimum integer does behave ... fuck, I was wrong because of this integer...