Is it faster to count down than it is to count up?

Posted by Bob on Stack Overflow See other posts from Stack Overflow or by Bob
Published on 2010-05-12T21:56:13Z Indexed on 2010/05/13 1:44 UTC
Read the original article Hit count: 177

Our computer science teacher once said that for some reason it is more efficient to count down that count up. For example if you need to use a FOR loop and the loop index is not used somewhere (like printing a line of N * to the screen) I mean that code like this :

for (i=N; i>=0; i--)  
  putchar('*');  

is better than:

for (i=0; i<N; i++)  
  putchar('*');  

Is it really true? and if so does anyone know why?

© Stack Overflow or respective owner

Related posts about c

    Related posts about programming-languages