public static double getPow(int base, int index)
    {
        if (index == 0) return 1;
        if (index == 1) return base;
        
        boolean isNeg = false;
        
        if (index < 0)
        {
            index *= -1;
            isNeg = true;
        }
        
        if (index % 2 == 0)
        {
            if (isNeg)
                return 1.0/(getPow(base, index/2)*getPow(base, index/2));
                
            return getPow(base, index/2)*getPow(base, index/2);
        }
        
        if (isNeg)
            return 1.0/(base*getPow(base, index/2)*getPow(base,index/2));
        
        return base*getPow(base, index/2)*getPow(base,index/2);
    }