title: Hashing to Negative Values
body: <p>Pretty much the title: I'm hashing a bunch of names (10000-ish) and some are outputting as negative. (table size is 20011).  </p>
  
  <p>The hash function in question is: </p>
  
  <pre><code>public static long hash2 ( String key ){
    int hashVal = 0;
      for( int i = 0; i &lt; key.length(); i++ )
        hashVal = (37 * hashVal) + key.charAt(i);
    return hashVal % 20011;
  }
  </code></pre>
  
  <p>I dug around and I think I have to do something to do with "wrap around." But I don't know how to go about that. </p>