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