#pragma once #include #include /** \file */ /** \defgroup fixpoint : 24/8bit Fixpoint Support \code #include \endcode Function */ typedef int32_t fp248_t; #define FP248_FRAC 8 #define FP248_MASK (0xFFFFFFFF >> (32-FP248_FRAC)) float fp248_to_float (fp248_t value); fp248_t fp248_from_float (float value); static inline fp248_t fp248_from_int32 (int32_t value) { return (fp248_t)(value << FP248_FRAC); }; static inline int32_t fp248_to_int32 (fp248_t value) { return (int32_t)(value >> FP248_FRAC); }; static inline fp248_t fp248_fraction (fp248_t value) { return value & FP248_MASK; }; static inline fp248_t fp248_add ( fp248_t a, fp248_t b ) { return a + b; }; static inline fp248_t fp248_sub ( fp248_t a, fp248_t b ) { return a - b; }; static inline fp248_t fp248_mul ( fp248_t a, fp248_t b ) { return (fp248_t)( ((int64_t)a * (int64_t)b) >> FP248_FRAC ); }; static inline fp248_t fp248_div ( fp248_t a, fp248_t b ) { return (fp248_t)( ((int64_t)a << FP248_FRAC) / b ); }; #include /* #define FP_PI fp_make(M_PI) #define FP_2PI (2*FP_PI) #define FP_SQRT_2 fp_make(1.414213562373095) #define FP_INV_SQRT_2 fp_make(0.707106781) #define FP_SQRT_3 fp_make(1.73205080756887729352) #define FP_INV_SQRT_3 fp_make(0.577350269) */