classSolution { public: doublePower(double base, int e){ if (e < 0) { return1.0 / Power(base, -e); } double res = 1.0; double t = base; while (e) { if (e & 1) res = res * t; t = t * t; e >>= 1; //执行次数是1不同于e = e & (e - 1) } /* double res = 1.0; for (int i = 0; i < e; ++i) { res *= base; } */ return res; } };