title: Right shifting negative numbers in C
body: <p>I have C code in which I do the following.</p>
  
  <pre><code>int nPosVal = +0xFFFF;   // + Added for ease of understanding
  int nNegVal = -0xFFFF;   // - Added for valid reason
  </code></pre>
  
  <p>Now when I try</p>
  
  <pre><code>printf ("%d %d", nPosVal &gt;&gt; 1, nNegVal &gt;&gt; 1);
  </code></pre>
  
  <p>I get</p>
  
  <pre><code>32767 -32768
  </code></pre>
  
  <p>Is this expected?</p>
  
  <p>I am able to think something like</p>
  
  <pre><code>65535 &gt;&gt; 1 = (int) 32767.5 = 32767
  -65535 &gt;&gt; 1 = (int) -32767.5 = -32768
  </code></pre>
  
  <p>That is, -32767.5 is rounded off to -32768. </p>
  
  <p>Is this understanding correct?</p>