fix16.h: provide fix16_from-like compile-time macros
This commit is contained in:
parent
d9068688be
commit
ac37834fe6
|
@ -42,6 +42,12 @@ static inline fix16_t fix16_from_int(int a) { return a * fix16_one; }
|
|||
static inline float fix16_to_float(fix16_t a) { return (float)a / fix16_one; }
|
||||
static inline double fix16_to_dbl(fix16_t a) { return (double)a / fix16_one; }
|
||||
|
||||
/* Static inline functions cannot be used to determine compile-time values,
|
||||
* so use this expression instead if needed. */
|
||||
#define FIX16_C_FROM_INT(a) ((a) * fix16_one)
|
||||
#define FIX16_C_FROM_FLOAT(a) (((float)(a) * fix16_one) >= 0 ? \
|
||||
(((float)(a) * fix16_one)) + 0.5f : ((float)(a) * fix16_one) - 0.5f)
|
||||
|
||||
static inline int fix16_to_int(fix16_t a)
|
||||
{
|
||||
#ifdef FIXMATH_NO_ROUNDING
|
||||
|
|
Loading…
Reference in New Issue