From a38a5c214b685ec3c9f80040092fcd78310ad863 Mon Sep 17 00:00:00 2001 From: Alen Frost Date: Sat, 27 Feb 2021 08:56:13 +0530 Subject: [PATCH] Fixing issue reported in https://github.com/perezd/node-murmurhash/issues/10 --- murmurhash.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/murmurhash.js b/murmurhash.js index 6a73210..a4bbc73 100644 --- a/murmurhash.js +++ b/murmurhash.js @@ -117,7 +117,14 @@ h1 = ((((h1 & 0xffff) * 0xc2b2ae35) + ((((h1 >>> 16) * 0xc2b2ae35) & 0xffff) << 16))) & 0xffffffff; h1 ^= h1 >>> 16; - return h1 >>> 0; + h1 = h1 >>> 0; + + if (h1 & 0x80000000 == 0) { + return h1; + } + else { + return -( (h1 ^ 0xFFFFFFFF) + 1 ) + } } var murmur = MurmurHashV3;