[BangPypers] Hash function that returns unsigned integer
phil.nabble at hanjinet.org
Fri Aug 31 15:56:10 CEST 2012
The probability of getting non unique values is logically multiplied by 2 using the modulo method.
If you don't mind dealing with long integers, you can simply add the absolute value of the minimum integer: hash(value) + sys.maxint + 1.
In any case, i think it's better to use sys.maxint, instead of 2**32.
> Will that be unique(near unique)? Want to make sure hashing someother string will not produce the same hash value.
>> Just modulo the hash function `hash_value % (2**32)`
>>> Is anyone aware of any non-cryptographic hash function whose value is only postive integer. Pythons inbuilt hash function is a signed integer.
More information about the BangPypers