From ec364ab4c116853588d604cd0bc699adbb76fea2 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 5 Mar 2021 07:44:34 -0800 Subject: 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. --- hash.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hash.c b/hash.c index 1cbc8285..2cdbdae2 100644 --- a/hash.c +++ b/hash.c @@ -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) { -- cgit v1.2.3