awips2/nativeLib/rary.cots.g2clib/int_power.c
Steve Harris ba884f2a27 14.1.1-9 baseline
Former-commit-id: 5a0a40e67c [formerly f8f995b697 [formerly 0d10fff4b09db0e4b0b8bcf7481f5f13af0943f5]]
Former-commit-id: f8f995b697
Former-commit-id: a32eadf384
2013-11-15 12:47:49 -05:00

30 lines
462 B
C
Executable file

#include "grib2.h"
/*
* w. ebisuzaki
*
* return x**y
*
*
* input: double x
* int y
*/
double int_power(double x, g2int y) {
double value;
if (y < 0) {
y = -y;
x = 1.0 / x;
}
value = 1.0;
while (y) {
if (y & 1) {
value *= x;
}
x = x * x;
y >>= 1;
}
return value;
}