cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=7bb229d4be23ffcc4947b453880a5c0f9f7a12c6

commit 7bb229d4be23ffcc4947b453880a5c0f9f7a12c6
Author: Cedric BAIL <ced...@osg.samsung.com>
Date:   Mon Dec 19 12:03:49 2016 -0800

    eina: add general purpose function to compar float and double.
---
 src/lib/eina/eina_util.h | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/src/lib/eina/eina_util.h b/src/lib/eina/eina_util.h
index c1ea02f..66e0d17 100644
--- a/src/lib/eina/eina_util.h
+++ b/src/lib/eina/eina_util.h
@@ -19,6 +19,8 @@
 #ifndef EINA_UTIL_H_
 #define EINA_UTIL_H_
 
+#include <float.h>
+
 /**
  * @addtogroup Eina_Tools_Group Tools
  *
@@ -48,6 +50,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)
+
+/**
  * @}
  */
 

-- 


Reply via email to