public static double pow(double x, int n) {
		if (n < 0) {
			x = 1 / x;
			n = -n;
		}
		if (n == 0)
			return 1;
		double result = 1;
		double temp = x;
		while (n > 0) {
			if ((n & 1) != 0)
				result = result * temp;
			temp = temp * temp;
			n /= 2;
		}
		return result;
	}