eccodes/src/grib_scaling.h

22 lines
346 B
C++

#pragma once
/* Return n to the power of s */
template <typename T>
constexpr T codes_power(long s, long n)
{
T divisor = 1.0;
if (s == 0)
return 1.0;
if (s == 1)
return n;
while (s < 0) {
divisor /= n;
s++;
}
while (s > 0) {
divisor *= n;
s--;
}
return divisor;
}