mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-01-15 22:01:36 -08:00
Long doubles have extra, unused bits which should not be used for hashing
This commit is contained in:
parent
198a58f626
commit
99b5c72283
1 changed files with 8 additions and 2 deletions
10
src/c/hash.d
10
src/c/hash.d
|
|
@ -59,7 +59,10 @@ _hash_eql(cl_hashkey h, cl_object x)
|
|||
return hash_string(h, (unsigned char*)&df(x), sizeof(df(x)));
|
||||
#ifdef ECL_LONG_FLOAT
|
||||
case t_longfloat: {
|
||||
long double d = ecl_long_float(x);
|
||||
/* We coerce to double because long double has extra bits
|
||||
* that give rise to different hash key and are not
|
||||
* meaningful */
|
||||
double d = ecl_long_float(x);
|
||||
return hash_string(h, (unsigned char*)&d, sizeof(d));
|
||||
}
|
||||
#endif
|
||||
|
|
@ -135,7 +138,10 @@ _hash_equal(int depth, cl_hashkey h, cl_object x)
|
|||
}
|
||||
# ifdef ECL_LONG_FLOAT
|
||||
case t_longfloat: {
|
||||
long double f = ecl_long_float(x);
|
||||
/* We coerce to double because long double has extra bits
|
||||
* that give rise to different hash key and are not
|
||||
* meaningful */
|
||||
double f = ecl_long_float(x);
|
||||
if (f == 0.0) f = 0.0;
|
||||
return hash_string(h, (unsigned char*)&f, sizeof(f));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue