From 1a8633a0fe2f1b795d9960447e6ca33cf71d6f93 Mon Sep 17 00:00:00 2001 From: jjgarcia Date: Sun, 28 Sep 2008 20:14:18 +0000 Subject: [PATCH] -0.0 and 0.0 do no longer compare EQL --- src/CHANGELOG | 2 ++ src/c/predicate.d | 15 +++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/CHANGELOG b/src/CHANGELOG index 61d2ca208..d06939fe3 100644 --- a/src/CHANGELOG +++ b/src/CHANGELOG @@ -109,6 +109,8 @@ ECL 8.9.0: - The reader and the printer now understand negative zeros. + - Negative and nonnegative zeros are not EQL. + ;;; Local Variables: *** ;;; mode:text *** ;;; fill-column:79 *** diff --git a/src/c/predicate.d b/src/c/predicate.d index 0ba28b7ba..3ae0c65df 100644 --- a/src/c/predicate.d +++ b/src/c/predicate.d @@ -16,6 +16,7 @@ */ #include +#include cl_object cl_identity(cl_object x) @@ -254,6 +255,12 @@ cl_eq(cl_object x, cl_object y) @(return ((x == y) ? Ct : Cnil)) } +#ifdef signbit +# define float_eql(a,b) (((a) == (b)) && (signbit((a)) == signbit((b)))) +#else +# define float_eql(a,b) (((a) == (b))) +#endif + bool ecl_eql(cl_object x, cl_object y) { @@ -272,15 +279,15 @@ ecl_eql(cl_object x, cl_object y) ecl_eql(x->ratio.den, y->ratio.den)); #ifdef ECL_SHORT_FLOAT case t_shortfloat: - return ecl_short_float(x) == ecl_short_float(y); + return float_eql(ecl_short_float(x),ecl_short_float(y)); #endif case t_singlefloat: - return (sf(x) == sf(y)); + return float_eql(sf(x),sf(y)); case t_doublefloat: - return (df(x) == df(y)); + return float_eql(df(x),df(y)); #ifdef ECL_LONG_FLOAT case t_longfloat: - return ecl_long_float(x) == ecl_long_float(y); + return float_eql(ecl_long_float(x),ecl_long_float(y)); #endif case t_complex: return (ecl_eql(x->complex.real, y->complex.real) &&