题目链接
https://leetcode.cn/problems/shu-zhi-de-zheng-shu-ci-fang-lcof/
思路
代码
class Solution {
public double myPow(double x, int n) {
double res=1.0;
long b=n;
if(b==0){
return 1;
}
if(b<0){
x=1/x;
b=-b;
}
while (b>0){
if((b&1)==1) res*=x;
x*=x;
b=b>>1;
}
return res;
}
}