Hi mike, This isn't good for a number of reasons... first the non-inline nature will add more symbols and a reasonable penalty. Secondly it just pushes the warning out of the code... to do something like that, maybe it's more reasonable to just turn the comparison into a memcmp() if we're looking for an identical value, usually to skip computations when it didn't change (although there a reasonable epsilon would increase hit ratio and speed up even further).
1 - static inline this kind of things; 2 - to achieve what you're proposing (not using an epsilon), memcmp(&a, &b) == 0 would be better (and likely faster since compilers will expand that to comparing the bytes without any call). On Fri, Jan 6, 2017 at 3:57 PM, Mike Blumenkrantz <michael.blumenkra...@gmail.com> wrote: > discomfitor pushed a commit to branch master. > > http://git.enlightenment.org/core/efl.git/commit/?id=1b4c26be8e9630ae0c367b914f893161c968799a > > commit 1b4c26be8e9630ae0c367b914f893161c968799a > Author: Mike Blumenkrantz <zm...@osg.samsung.com> > Date: Fri Jan 6 12:57:46 2017 -0500 > > 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 > --- > src/lib/eina/eina_util.c | 32 ++++++++++++++++++++++++++++++++ > src/lib/eina/eina_util.h | 20 ++++++++++++++++++++ > 2 files changed, 52 insertions(+) > > diff --git a/src/lib/eina/eina_util.c b/src/lib/eina/eina_util.c > index 62e1a79..a358884 100644 > --- a/src/lib/eina/eina_util.c > +++ b/src/lib/eina/eina_util.c > @@ -100,3 +100,35 @@ eina_environment_tmp_get(void) > return tmp; > #endif > } > + > +#if defined(_MSC_VER) > +#elif defined(__clang__) > +# pragma clang diagnostic push > +# pragma clang diagnostic ignored "-Wfloat-equal" > +#elif defined(__GNUC__) > +# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406 > +# pragma GCC diagnostic push > +# pragma GCC diagnostic ignored "-Wfloat-equal" > +# endif > +#endif > + > +EAPI Eina_Bool > +eina_dbleq(double a, double b) > +{ > + return a == b; > +} > + > +EAPI Eina_Bool > +eina_flteq(float a, float b) > +{ > + return a == b; > +} > + > +#if defined(_MSC_VER) > +#elif defined(__clang__) > +# pragma clang diagnostic pop > +#elif defined(__GNUC__) > +# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406 > +# pragma GCC diagnostic pop > +# endif > +#endif > diff --git a/src/lib/eina/eina_util.h b/src/lib/eina/eina_util.h > index 66e0d17..3796dcb 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); > EAPI const char *eina_environment_tmp_get(void); > > /** > + * @brief Warningless comparison of doubles using == > + * @param a First member to compare > + * @param b Second member to compare > + * > + * @return @c true if two doubles match > + * @since 1.19 > + */ > +EAPI Eina_Bool eina_dbleq(double a, double b); > + > +/** > + * @brief Warningless comparison of floats using == > + * @param a First member to compare > + * @param b Second member to compare > + * > + * @return @c true if two floats match > + * @since 1.19 > + */ > +EAPI Eina_Bool eina_flteq(float a, float b); > + > +/** > * @brief Safe comparison of float > * @param a First member to compar > * @param b Second member to compar > > -- > > -- Gustavo Sverzut Barbieri -------------------------------------- Mobile: +55 (16) 99354-9890 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel