title: When a long integer is cast into a short one, what happened?
body: <p>I use java to copy one long integer y to a short integer x:</p>
  
  <pre><code>long y = 40002;
  short x = (short) y;
  System.out.println("x now equals " + x);
  </code></pre>
  
  <p>The result is: x now equals -25534.</p>
  
  <p>I tried to figure out how 40002 was cast into -25534, but I failed. The 40002 corresponds to 1001 1100 0100 0010, the -25534 corresponds to 1110 0011 1011 1110. Can any friend tell me what happened in this process? Thanks a lot!</p>