title: Find first "1" in binary number
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/9093323/efficient-bitwise-operations-for-counting-bits-or-find-the-rightleft-most-ones">Efficient bitwise operations for counting bits or find the right|left most ones</a>  </p>
  </blockquote>
  
  
  
  <p>Is there a fast way to find the first 1 in a (32 bit) binary number?</p>
  
  <p>e.g. if I have the number 00000000 00000000 00000000 10000000</p>
  
  <p>I want to calculate the value "7" (or "24", if read from the other side) since the first zero in the number is stored in the 7th bit from the right. </p>
  
  <p>Is there a faster way to do this than</p>
  
  <pre><code>int pos=0;
  int number = 127; //binary from above
  while ((number&gt;&gt;pos) &gt; 0) { pos++; }
  </code></pre>
  
  <p>?</p>
  
  <p>Perhaps a specific x86 assembler instruction?</p>