public double myPow_ii(double x, int n) {
        if (n == 0)
            return 1;
        double ans = 1.0;
        if (n < 0) {
            x = 1 / x;
            n = -1 * n;
        }
        while (n > 0) {
            if (n % 2 == 0) {
                x *= x;
                n /= 2;
            } else {
                ans = ans * x;
                n -= 1;
            }
        }
        return ans;
    }