1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

imath: add powi() function

This commit is contained in:
Benjamin Valentin 2023-03-22 14:28:11 +01:00 committed by Benjamin Valentin
parent eefa1b86b5
commit 34d002754b

View File

@ -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