>>365
>>362のアドバイスを基に改良
double pow2(int x, int n) {
    unsigned int bit = 1U << sizeof(unsigned int) * CHAR_BIT - 1;
    double result = 1.;
    if (n < 0) return 1./pow2(x, -n);
    do {
        result *= result;
        if (bit & n) result *= x;
    } while (bit >>= 1);
    return result;
}