Advertisement

09.16.2003 at 11:08PM PDT, ID: 20740926
[x]
Attachment Details

simple integer hash function

Asked by CBasheer in C Programming Language

Tags: hash, integer, function, simple

Hi all,
 I understood the following is a simple integer hash function. But I din't understand
how it works?.  For example if I pass 5100 as key to this function whit it'll return back to me!>

Please explain step by step (atleast for operator for +, ^, << , >> )


Thanks
-BAS.


unsigned int inthash(unsigned int key)
{
 key += (key << 12);
 key ^= (key >> 22);
 key += (key << 4);
 key ^= (key >> 9);
 key += (key << 10);
 key ^= (key >> 2);
 key += (key << 7);
 key ^= (key >> 12);
 return key;
}

Start Free Trial
 
Keywords: simple integer hash function
 
Loading Advertisement...
 
[+][-]09.16.2003 at 11:25PM PDT, ID: 9376040

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.16.2003 at 11:33PM PDT, ID: 9376071

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: C Programming Language
Tags: hash, integer, function, simple
Sign Up Now!
Solution Provided By: sunnycoder
Participating Experts: 2
Solution Grade: B
 
 
[+][-]09.17.2003 at 12:10AM PDT, ID: 9376204

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32