awips2/nativeLib/rary.cots.g2clib/int_power.c
Bryan Kowal 9a472e1bbe Issue #2396 - updated grib2.so to use a newer version of g2clib
Former-commit-id: 6730ef07554b6e335427bcf08dded302fcc4a398
2013-10-16 12:54:58 -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;
}