lastguest / murmurhash-php

PHP userland implementation of MurmurHash3
MIT License
128 stars 37 forks source link

Unsigned right shift #4

Closed mp31415 closed 8 years ago

mp31415 commented 8 years ago

PHP supports only signed integers and does not have unsigned right shift operation (>>>). As a result this implementation may produce different results than other murmur3 implementations. If I replace all >> operations with a function that performs unsigned right shift, then the results are back to normal.

One of the implementations for the shift may be found on StackOverflow, I copy it here for convenience:

function uRShift($a, $b) { if($b == 0) return $a; return ($a >> $b) & ~(1<<(8*PHP_INT_SIZE-1)>>($b-1)); }

Thanks.

lastguest commented 8 years ago

Can you make a pull request? Thanks.