Skip to content

Commit

Permalink
use Math.pow() instead of ** for older Node versions - closes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
duhaime committed Jun 2, 2018
1 parent b810de8 commit d89cc72
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/minhash.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var Minhash = function(config) {
// prime is the smallest prime larger than the largest
// possible hash value (max hash = 32 bit int)
this.prime = 4294967311;
this.maxHash = 2**32-1;
this.maxHash = Math.pow(2, 32) - 1;

// initialize the hash values as the maximum value
this.inithashvalues = function() {
Expand Down Expand Up @@ -51,14 +51,14 @@ var Minhash = function(config) {
this.hash = function(str) {
var hash = 0;
if (str.length == 0) {
return hash + (2**32/2-1);
return hash + this.maxHash;
}
for (var i = 0; i < str.length; i++) {
var char = str.charCodeAt(i);
hash = ((hash<<5)-hash)+char;
hash = hash & hash; // convert to a 32bit integer
}
return hash + (2**32/2-1);
return hash + this.maxHash;
}

// estimate the jaccard similarity to another minhash
Expand Down

0 comments on commit d89cc72

Please sign in to comment.