summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2016-12-19 12:03:49 -0800
committerCedric BAIL <cedric@osg.samsung.com>2016-12-19 16:33:46 -0800
commit7bb229d4be23ffcc4947b453880a5c0f9f7a12c6 (patch)
tree953f11144d3ce3f9a3e3fc6800b82c24ac18b2bc /src
parent00f8cc45667ed33418533d000ab909744d8149ee (diff)
eina: add general purpose function to compar float and double.
Diffstat (limited to 'src')
-rw-r--r--src/lib/eina/eina_util.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/lib/eina/eina_util.h b/src/lib/eina/eina_util.h
index c1ea02f68e..66e0d17f6d 100644
--- a/src/lib/eina/eina_util.h
+++ b/src/lib/eina/eina_util.h
@@ -19,6 +19,8 @@
19#ifndef EINA_UTIL_H_ 19#ifndef EINA_UTIL_H_
20#define EINA_UTIL_H_ 20#define EINA_UTIL_H_
21 21
22#include <float.h>
23
22/** 24/**
23 * @addtogroup Eina_Tools_Group Tools 25 * @addtogroup Eina_Tools_Group Tools
24 * 26 *
@@ -48,6 +50,24 @@ EAPI const char *eina_environment_home_get(void);
48EAPI const char *eina_environment_tmp_get(void); 50EAPI const char *eina_environment_tmp_get(void);
49 51
50/** 52/**
53 * @brief Safe comparison of float
54 * @param a First member to compar
55 * @param b Second member to compar
56 *
57 * @return @c true if two floats match
58 */
59#define EINA_FLT_CMP(a, b) (fabsf((float)a - (float)b) <= FLT_EPSILON)
60
61/**
62 * @brief Safe comparison of double
63 * @param a First member to compar
64 * @param b Second member to compar
65 *
66 * @return @c true if two double match
67 */
68#define EINA_DBL_CMP(a, b) (fabs((double)a - (double)b) <= DBL_EPSILON)
69
70/**
51 * @} 71 * @}
52 */ 72 */
53 73