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:
parent
eefa1b86b5
commit
34d002754b
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user