/* IPOW.C - Raise a number to an integer power (by repeated squaring) */ double ipow( double x, int n ) /* return x^n */ { double t = 1.0; if (n < 0) { n = -n; x = 1.0 / x; /* error if x == 0. Good */ } if (x == 0.0) return 0.0; while (n) { if (n & 1) t *= x; n >>= 1; x *= x; } return t; }