title: Why if(i) is taking more time than if(0 != i)
body: <p>Why if(i) is taking more time than if(0 != i), please suggest which is a better way to check for arguments to a function.</p>
  
  <p>Please find below code snippet:</p>
  
  <pre><code>#include &lt;sys/time.h&gt;
  #include &lt;stdio.h&gt;
  
  int main()
  {
      struct timeval  lBefore,lAfter,lResult;
      int i,j = 0;
  
      timerclear(&amp;lBefore);
      timerclear(&amp;lAfter);
  
      gettimeofday(&amp;lBefore,NULL);
  
      for(i = 0; i &lt; 0xFFFFFF; i++)
      {
          if(i)
          {
              j++;
          }
      }
  
      gettimeofday(&amp;lAfter,NULL);
  
      timersub(&amp;lAfter,&amp;lBefore,&amp;lResult);
  
      printf("[%d]%ld:%ld\n",j,lResult.tv_sec,lResult.tv_usec);
  
      j = 0;
  
      gettimeofday(&amp;lBefore,NULL);
  
      for(i = 0; i &lt; 0xFFFFFF; i++)
      {
          if(0 != i)
          {
              j++;
          }
      }
  
      gettimeofday(&amp;lAfter,NULL);
  
      timersub(&amp;lAfter,&amp;lBefore,&amp;lResult);
  
      printf("[%d]%ld:%ld\n",j,lResult.tv_sec,lResult.tv_usec);
  
      return 0;
  }
  </code></pre>
  
  <p>Code output:</p>
  
  <pre><code>sh-4.2$ main
  </code></pre>
  
  <blockquote>
    <p>[16777214]0:79030<br>
    [16777214]0:55605<br>
    sh-4.2$ main<br>
    [16777214]0:76910<br>
    [16777214]0:53657<br>
    sh-4.2$ main<br>
    [16777214]0:74696<br>
    [16777214]0:51295</p>
  </blockquote>