0.code
class Solution {
public double myPow(double x, int n) {
if(x==0){
return 0;
}
double res = 1.0;
long b = n;
if(b<0){
b = -b;
x = 1/x;
}
while(b>0){
if((b&1)==1){
res = res*x;
}
x = x*x;
b=b>>1;
}
return res;
}
}
网友评论