mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-25 06:23:53 +01:00
Merge pull request #15270 from benpicco/sys/fac-gcd
sys/frac: make gcd32() public
This commit is contained in:
commit
ae7a41a60c
@ -24,15 +24,7 @@
|
||||
#define ENABLE_DEBUG (0)
|
||||
#include "debug.h"
|
||||
|
||||
/**
|
||||
* @brief compute greatest common divisor of @p u and @p v
|
||||
*
|
||||
* @param[in] u first operand
|
||||
* @param[in] v second operand
|
||||
*
|
||||
* @return Greatest common divisor of @p u and @p v
|
||||
*/
|
||||
static uint32_t gcd32(uint32_t u, uint32_t v)
|
||||
uint32_t gcd32(uint32_t u, uint32_t v)
|
||||
{
|
||||
/* Source: https://en.wikipedia.org/wiki/Binary_GCD_algorithm#Iterative_version_in_C */
|
||||
unsigned shift;
|
||||
@ -81,7 +73,7 @@ static uint32_t gcd32(uint32_t u, uint32_t v)
|
||||
return u << shift;
|
||||
}
|
||||
|
||||
uint32_t frac_long_divide(uint32_t num, uint32_t den, int *prec, uint32_t *rem)
|
||||
static uint32_t frac_long_divide(uint32_t num, uint32_t den, int *prec, uint32_t *rem)
|
||||
{
|
||||
/* Binary long division with adaptive number of fractional bits */
|
||||
/* The result will be a Qx.y number where x is the number of bits in the
|
||||
|
||||
@ -55,6 +55,16 @@ typedef struct {
|
||||
uint8_t shift; /**< exponent */
|
||||
} frac_t;
|
||||
|
||||
/**
|
||||
* @brief Compute greatest common divisor of @p u and @p v
|
||||
*
|
||||
* @param[in] u first operand
|
||||
* @param[in] v second operand
|
||||
*
|
||||
* @return Greatest common divisor of @p u and @p v
|
||||
*/
|
||||
uint32_t gcd32(uint32_t u, uint32_t v);
|
||||
|
||||
/**
|
||||
* @brief Initialize frac_t struct
|
||||
*
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user