public static double pow(double a, int b){
        if (a == 0.0) {
            if (b == 0) {
                throw new IllegalArgumentException("0^0 not supported");
            } else {
                return +0;
            }
        }
        if (b == 0) {
            return 1.0;
        }

        // a,b <> 0
        double result = a;
        int n = Math.abs(b);
        for(int i = 2; i <= n; i++){
            result *= a;
        }
        
        if (b < 0) {
            result = 1/result;
        }
        return result;
    }