public class Solution {
    public double Power(double base, int exponent) {
        int abs = exponent >= 0 ? exponent : -exponent;
        if (abs == 0) {
            return 1.0;
        }
        if (base == 0) {
            return 0.0;
        }
        double res = 1.0;
        for (int i = 0; i < abs; i++) {
            res *= base;
        }
        return exponent > 0 ? res : 1.0 / res;
    }
}