eina: add general purpose function to compar float and double.

This commit is contained in:
Cedric BAIL 2016-12-19 12:03:49 -08:00
parent 00f8cc4566
commit 7bb229d4be
1 changed files with 20 additions and 0 deletions

View File

@ -19,6 +19,8 @@
#ifndef EINA_UTIL_H_
#define EINA_UTIL_H_
#include <float.h>
/**
* @addtogroup Eina_Tools_Group Tools
*
@ -47,6 +49,24 @@ EAPI const char *eina_environment_home_get(void);
*/
EAPI const char *eina_environment_tmp_get(void);
/**
* @brief Safe comparison of float
* @param a First member to compar
* @param b Second member to compar
*
* @return @c true if two floats match
*/
#define EINA_FLT_CMP(a, b) (fabsf((float)a - (float)b) <= FLT_EPSILON)
/**
* @brief Safe comparison of double
* @param a First member to compar
* @param b Second member to compar
*
* @return @c true if two double match
*/
#define EINA_DBL_CMP(a, b) (fabs((double)a - (double)b) <= DBL_EPSILON)
/**
* @}
*/