title: Right shift with zeros at the beginning
body: <p>I'm trying to do a kind of left shift that would add zeros at the beginning instead of ones. For example, if I left shift <code>0xff</code>, I get this:</p>
  
  <pre><code>0xff &lt;&lt; 3 = 11111000
  </code></pre>
  
  <p>However, if I right shift it, I get this:</p>
  
  <pre><code>0xff &gt;&gt; 3 = 11111111
  </code></pre>
  
  <p>Is there any operation I could use to get the equivalent of a left shift? i.e. I would like to get this:</p>
  
  <pre><code>00011111
  </code></pre>
  
  <p>Any suggestion?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>To answer the comments, here is the code I'm using:</p>
  
  <pre><code>int number = ~0;
  number = number &lt;&lt; 4;   
  std::cout &lt;&lt; std::hex &lt;&lt; number &lt;&lt; std::endl;
  
  number = ~0;
  number = number &gt;&gt; 4;
  std::cout &lt;&lt; std::hex &lt;&lt; number &lt;&lt; std::endl;
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>fffffff0
  ffffffff
  </code></pre>
  
  <p>Since it seems that in general it should work, I'm interested as to why this specific code doesn't. Any idea?</p>