title: Performance of comparisons in C++ ( foo >= 0 vs. foo != 0 )
body: <p>I've been working on a piece of code recently where performance is very important, and essentially I have the following situation:</p>
  
  <pre><code>int len = some_very_big_number;
  int counter = some_rather_small_number;
  
  for( int i = len; i &gt;= 0; --i ){
      while( counter &gt; 0 &amp;&amp; costly other stuff here ){
          /* do stuff */
          --counter;
      }
      /* do more stuff */
  }
  </code></pre>
  
  <p>So here I have a loop that runs very often and for a certain number of runs the while block will be executed as well until the variable <code>counter</code> is reduced to zero and then the while loop will not be called because the first expression will be false.</p>
  
  <p>The question is now, if there is a difference in performance between using<br>
  <code>counter &gt; 0</code> and <code>counter != 0</code>?<br>
  I suspect there would be, does anyone know specifics about this.</p>