Skip to content

Instantly share code, notes, and snippets.

@funny-falcon
Created August 14, 2012 07:47
Show Gist options
  • Save funny-falcon/3347272 to your computer and use it in GitHub Desktop.
Save funny-falcon/3347272 to your computer and use it in GitHub Desktop.
Simple int32 hash with relatively good avalance
/* it has avalance ~ 33.3 measured by http://baagoe.org/en/w/index.php/Avalanche_on_integer_hash_functions */
/* it is not the best, but i think it is good enough */
uint32_t hash(uint32_t n) {
n ^= n >> 16;
n *= 0xd5b25599;
return n + (n >> 16);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment