title: C++ Trying to shift number right by 32 gives two different results
body: <p>I was writing a small program to get some experience with bit manipulation and I encountered this situation. I was trying to create a mask that sets 0`s all the bits from MSB to some number n. The problem arises when my n is 32. Here is some code that demonstrates the problem.</p>
  
  <pre><code>int n = (sizeof(int) * 8) - 0; //Here n is basically set to 32.
      std::cout &lt;&lt; n &lt;&lt; std::endl; //And indeed, this prints 32.
  
      //here I expect to see 0 (basically all 32 bits of the number should be 0`s, but I see the opposite, all bits are set to 1.)
      std::cout &lt;&lt; ((unsigned) ~0 &gt;&gt; n) &lt;&lt; std::endl;
  
      //And this indeed does what I expected and all 32 bits of the nuber are set to 0`s.
      std::cout &lt;&lt; ((unsigned) ~0 &gt;&gt; 32) &lt;&lt; std::endl;
  </code></pre>
  
  <p>my question is, since n = 32, why am I seeing 2 different results here wherein 1st one I am seeing 32 <code>s and in the 2nd case, I am seeing 32 0</code>s? </p>