diff options
Diffstat (limited to 'include/gmisc/gmisc.h')
| -rw-r--r-- | include/gmisc/gmisc.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/include/gmisc/gmisc.h b/include/gmisc/gmisc.h index 998dda50..ff3d0c76 100644 --- a/include/gmisc/gmisc.h +++ b/include/gmisc/gmisc.h @@ -51,6 +51,7 @@ typedef int32_t fixed; */ #define FIXED(x) ((fixed)(x)<<16) /* @< integer to fixed */ #define NONFIXED(x) ((x)>>16) /* @< fixed to integer */ +#define FIXED0_5 32768 /* @< 0.5 as a fixed (used for rounding) */ #define FP2FIXED(x) ((fixed)((x)*65536.0)) /* @< floating point to fixed */ #define FIXED2FP(x) ((double)(x)/65536.0) /* @< fixed to floating point */ /* @} */ @@ -183,6 +184,23 @@ extern "C" { /** @} */ #endif +#if GMISC_NEED_INVSQRT + /** + * @brief Fast inverse square root function (x^-1/2) + * @return The approximate inverse square root + * + * @param[in] n The number to find the inverse square root of + * + * @note This function generates an approximate result. Higher accuracy (at the expense + * of speed) can be obtained by modifying the source code (the necessary line + * is already there - just commented out). + * @note This function relies on the internal machine format of a float and a long. + * If your machine architecture is very unusual this function may not work. + * + * @api + */ + float invsqrt(float n); +#endif #ifdef __cplusplus } #endif |
