title: Hashtable hashing avoid negative hashcode
body: <p>I am wondering why does <a href="http://www.docjar.com/html/api/java/util/Hashtable.java.html" rel="noreferrer">Hashtable</a> avoid using negative hashcode ? </p>
  
  <pre><code>int hash = key.hashCode();
  int index = (hash &amp; 0x7FFFFFFF) % tab.length;
  </code></pre>
  
  <p>Where <code>(hash &amp; 0x7FFFFFFF)</code> makes the signed bit to be 0 to positive, but why couldn't we treat the signed 32 bit integer as unsigned ? or even use the modular tricks to make it become positive. For example,</p>
  
  <pre><code>public static long int_mod(int hashcode, int tab_length){
       return (hashcode % tab_length + tab_length) % tab_length;  
  } 
  </code></pre>