Created
August 14, 2012 07:47
-
-
Save funny-falcon/3347272 to your computer and use it in GitHub Desktop.
Simple int32 hash with relatively good avalance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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