eina: add macros for determining whether floats are nonzero

this is a commonly-used functionality, so make it faster to write

@feature
This commit is contained in:
Mike Blumenkrantz 2017-01-06 12:57:46 -05:00
parent 1b4c26be8e
commit 16d28c6bc8
1 changed files with 18 additions and 0 deletions

View File

@ -78,6 +78,15 @@ EAPI Eina_Bool eina_flteq(float a, float b);
*/
#define EINA_FLT_CMP(a, b) (fabsf((float)a - (float)b) <= FLT_EPSILON)
/**
* @brief Determine if a float is nonzero
* @param a The float
*
* @return @c true if float is nonzero
* @since 1.19
*/
#define EINA_FLT_NONZERO(a) (!EINA_FLT_CMP((a), 0.0))
/**
* @brief Safe comparison of double
* @param a First member to compar
@ -87,6 +96,15 @@ EAPI Eina_Bool eina_flteq(float a, float b);
*/
#define EINA_DBL_CMP(a, b) (fabs((double)a - (double)b) <= DBL_EPSILON)
/**
* @brief Determine if a double is nonzero
* @param a The double
*
* @return @c true if double is nonzero
* @since 1.19
*/
#define EINA_DBL_NONZERO(a) (!EINA_DBL_CMP((a), 0.0))
/**
* @}
*/