Meaning of this for-loop written ina mex file

1 vue (au cours des 30 derniers jours)
Kasun Talwatta
Kasun Talwatta le 13 Oct 2011
Hi,
Can someone please shed some light about this particular for-loop that I came across.
for(ir = ir; ir<=temp; ir++){ }
The initial value seems to equal to each other !. What is the meaning of that ?

Réponse acceptée

Jan
Jan le 13 Oct 2011
It is simply a bad programming style. The "ir = ir" can be omitted:
for( ; ir <= temp; ir++) { }

Plus de réponses (1)

Kasun Talwatta
Kasun Talwatta le 13 Oct 2011
I found that it basically does ir = max(ir, ceil(temp)) thanks to a member from stackoverflow
  1 commentaire
James Tursa
James Tursa le 13 Oct 2011
Or an infinite loop. E.g. if ir is unsigned and temp is the max value (or greater) for that unsigned type, or if ir is a signed integer type and the compiler uses modulo arithmetic for signed integer overflows and temp is the max value (or greater) for that type, etc. etc.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by