Meaning of this for-loop written ina mex file

조회 수: 2 (최근 30일)
Kasun Talwatta
Kasun Talwatta 2011년 10월 13일
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 ?

채택된 답변

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

추가 답변 (1개)

Kasun Talwatta
Kasun Talwatta 2011년 10월 13일
I found that it basically does ir = max(ir, ceil(temp)) thanks to a member from stackoverflow
  댓글 수: 1
James Tursa
James Tursa 2011년 10월 13일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by