Answer the question
In order to leave comments, you need to log in
How to get a numeric hash of a given length?
There is a line consisting of Russian or any alphabet. You need to get its numeric hash of a given length. Even if this string consists of one letter or several hashes must have the same length. This is needed to sort alphabetically but through a numeric hash in order to quickly look up the first occurrence to display hints.
Answer the question
In order to leave comments, you need to log in
Take any hash function. For example, the Jenkins hash function.
uint32_t jenkins_one_at_a_time_hash(char *key, size_t len)
{
uint32_t hash, i;
for(hash = i = 0; i < len; ++i)
{
hash += key[i];
hash += (hash << 10);
hash ^= (hash >> 6);
}
hash += (hash << 3);
hash ^= (hash >> 11);
hash += (hash << 15);
return hash;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question