AnsweredAssumed Answered

while loop vs for loop

Question asked by MattZ on Apr 15, 2011
Latest reply on Apr 18, 2011 by MattZ

Hi All,

 

I'm working on modifying some BF537 code that I received from another company. Their code uses lots while loops such as:

 

i=0;

while (i<5) {

  some_function();

  i++;

}

 

Whereas I prefer to use for loops like this:

 

for (i=0; i<5; i++)

   some_function();

 

It is my understanding that logically these are the same thing. However, I'm relatively new to DSP programming and I'm wondering if there is some sort of behind the scenes optimization that operates on while loops versus for loops.

 

Does anyone know if there is a technical reason using the while loop implementation? Or is this just stylistic?

 

thanks in advance

-Matt

Outcomes