943,675 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 1238
  • C++ RSS
May 17th, 2009
0

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

Expand Post »
In an assignment involving cyclic shift hash codes, the instructions include the following code:
C++ Syntax (Toggle Plain Text)
  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?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
Daria Shmaria is offline Offline
25 posts
since Oct 2008
May 17th, 2009
0

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

Here is a good explanation of left shift (<<) and right shift (>>)
http://irc.essex.ac.uk/www.iota-six...._operators.asp

Dave
Featured Poster
Reputation Points: 437
Solved Threads: 204
Posting Virtuoso
daviddoria is offline Offline
1,968 posts
since Feb 2008
May 17th, 2009
0

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

daviddoria,

Thanks a lot! Your link was really helpful.
Reputation Points: 10
Solved Threads: 0
Light Poster
Daria Shmaria is offline Offline
25 posts
since Oct 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: classes in c++ programming help?
Next Thread in C++ Forum Timeline: Effective member function calls





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC