diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-03-05 07:44:34 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-03-05 07:44:34 -0800 |
commit | bc7859d87f7126814532a012c5ee0c7ce19e47ab (patch) | |
tree | a2380b2e2099c9b9a42320fe9fc8cadcbb8e19d1 /hash.c | |
parent | 3c7cbac43de030255055acf329d075f72b837e62 (diff) | |
download | txr-bc7859d87f7126814532a012c5ee0c7ce19e47ab.tar.gz txr-bc7859d87f7126814532a012c5ee0c7ce19e47ab.tar.bz2 txr-bc7859d87f7126814532a012c5ee0c7ce19e47ab.zip |
hashing: bug: hash-equal zero: floats and bignums.
hash.c (equal_hash): Do not multiply by the seed if it is
zero; substitute 1. Otherwise under the default seed of zero,
the hash becomes zero.
Diffstat (limited to 'hash.c')
-rw-r--r-- | hash.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -257,9 +257,9 @@ ucnum equal_hash(val obj, int *count, ucnum seed) lazy_str_force_upto(obj, num(*count - 1)); return equal_hash(obj->ls.prefix, count, seed); case BGNUM: - return mp_hash(mp(obj)) * seed; + return mp_hash(mp(obj)) * if3(seed, seed, 1); case FLNUM: - return hash_double(obj->fl.n) * seed; + return hash_double(obj->fl.n) * if3(seed, seed, 1); case COBJ: case CPTR: if (obj->co.ops->equalsub) { |