title: In C, what happens if we left shift the bits out of range and again right shift the values in the same operation
body: <p>In case of unsigned short I shifted 383 by 11 positions towards left and again in the same instruction shifted it by 15 positions right, I expected the value to be 1 but it was 27. But when I used both the shift operations in different instructions one after another(first left shift and then right), output was 1.
  here is a sample code :-</p>
  
  <pre><code>unsigned short seed = 383;
  printf("size of short: %d\n",sizeof(short));
  unsigned short seedout,seed1,seed2,seed3,seedout1;
  seed1 = (seed&lt;&lt;11);
  seed2 = (seed1&gt;&gt;15);
  seed3 = ((seed&lt;&lt;11)&gt;&gt;15);
  printf("seed1 :%d\t  seed2: %d\t seed3: %d\n",seed1,seed2,seed3);
  </code></pre>
  
  <p>and its <a href="https://i.stack.imgur.com/vNIMJ.png" rel="noreferrer">output</a> was :</p>
  
  <pre><code>size of short: 2
  seed1 :63488      seed2: 1       seed3: 23    
  seedout1: 8     seedout :382
  Process returned 0 (0x0)   execution time : 0.154 s
  </code></pre>