diff --git a/sys/include/imath.h b/sys/include/imath.h index b4175280dc..1f2ff5fcb1 100644 --- a/sys/include/imath.h +++ b/sys/include/imath.h @@ -117,6 +117,25 @@ static inline unsigned sqrti(unsigned x) return y0; } +/** + * @brief Returns the value of x to the power of y + * + * @param x base + * @param y exponent + * + * @return x^y + */ +static inline uint32_t powi(unsigned x, unsigned y) +{ + uint32_t res = 1; + + while (y--) { + res *= x; + } + + return res; +} + #ifdef __cplusplus } #endif