summaryrefslogtreecommitdiff
path: root/src/lib/eina
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2017-01-06 12:57:46 -0500
committerMike Blumenkrantz <zmike@osg.samsung.com>2017-01-06 12:57:08 -0500
commit1b4c26be8e9630ae0c367b914f893161c968799a (patch)
treec6675cb32c994b7ab15cda7fbcb42974ca702aab /src/lib/eina
parent6cf290faec98bebf25ec51630aa5879fefae9149 (diff)
eina: add functions for warningless exact comparisons of floats
in some cases a user does want to check exact values, so these functions should be used to indicate this intent needs windows support @feature
Diffstat (limited to 'src/lib/eina')
-rw-r--r--src/lib/eina/eina_util.c32
-rw-r--r--src/lib/eina/eina_util.h20
2 files changed, 52 insertions, 0 deletions
diff --git a/src/lib/eina/eina_util.c b/src/lib/eina/eina_util.c
index 62e1a79b42..a35888491d 100644
--- a/src/lib/eina/eina_util.c
+++ b/src/lib/eina/eina_util.c
@@ -100,3 +100,35 @@ eina_environment_tmp_get(void)
100 return tmp; 100 return tmp;
101#endif 101#endif
102} 102}
103
104#if defined(_MSC_VER)
105#elif defined(__clang__)
106# pragma clang diagnostic push
107# pragma clang diagnostic ignored "-Wfloat-equal"
108#elif defined(__GNUC__)
109# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406
110# pragma GCC diagnostic push
111# pragma GCC diagnostic ignored "-Wfloat-equal"
112# endif
113#endif
114
115EAPI Eina_Bool
116eina_dbleq(double a, double b)
117{
118 return a == b;
119}
120
121EAPI Eina_Bool
122eina_flteq(float a, float b)
123{
124 return a == b;
125}
126
127#if defined(_MSC_VER)
128#elif defined(__clang__)
129# pragma clang diagnostic pop
130#elif defined(__GNUC__)
131# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406
132# pragma GCC diagnostic pop
133# endif
134#endif
diff --git a/src/lib/eina/eina_util.h b/src/lib/eina/eina_util.h
index 66e0d17f6d..3796dcb392 100644
--- a/src/lib/eina/eina_util.h
+++ b/src/lib/eina/eina_util.h
@@ -50,6 +50,26 @@ EAPI const char *eina_environment_home_get(void);
50EAPI const char *eina_environment_tmp_get(void); 50EAPI const char *eina_environment_tmp_get(void);
51 51
52/** 52/**
53 * @brief Warningless comparison of doubles using ==
54 * @param a First member to compare
55 * @param b Second member to compare
56 *
57 * @return @c true if two doubles match
58 * @since 1.19
59 */
60EAPI Eina_Bool eina_dbleq(double a, double b);
61
62/**
63 * @brief Warningless comparison of floats using ==
64 * @param a First member to compare
65 * @param b Second member to compare
66 *
67 * @return @c true if two floats match
68 * @since 1.19
69 */
70EAPI Eina_Bool eina_flteq(float a, float b);
71
72/**
53 * @brief Safe comparison of float 73 * @brief Safe comparison of float
54 * @param a First member to compar 74 * @param a First member to compar
55 * @param b Second member to compar 75 * @param b Second member to compar