What do << and >> mean in cyclic shift hash codes?

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Oct 2008
Posts: 25
Reputation: Daria Shmaria is an unknown quantity at this point 
Solved Threads: 0
Daria Shmaria Daria Shmaria is offline Offline
Light Poster

What do << and >> mean in cyclic shift hash codes?

 
0
  #1
May 17th, 2009
In an assignment involving cyclic shift hash codes, the instructions include the following code:
  1. int hashCode(const char* p, int len)
  2. { unsigned int h = 0;
  3. for (int i = 0; i < len; i++)
  4. { h = (h << 5)|(h >> 27);
  5. h += (unsigned int)p[i];
  6. }
  7. return h;
  8. }

What do the >> and << in line 4 mean?
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 638
Reputation: daviddoria is a jewel in the rough daviddoria is a jewel in the rough daviddoria is a jewel in the rough 
Solved Threads: 46
daviddoria daviddoria is offline Offline
Practically a Master Poster

Re: What do << and >> mean in cyclic shift hash codes?

 
0
  #2
May 17th, 2009
Here is a good explanation of left shift (<<) and right shift (>>)
http://irc.essex.ac.uk/www.iota-six...._operators.asp

Dave
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 25
Reputation: Daria Shmaria is an unknown quantity at this point 
Solved Threads: 0
Daria Shmaria Daria Shmaria is offline Offline
Light Poster

Re: What do << and >> mean in cyclic shift hash codes?

 
0
  #3
May 17th, 2009
daviddoria,

Thanks a lot! Your link was really helpful.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC