DELPHI AREA
MESSAGE BOARD
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[For] A 'For to' which reacts like a 'for downto'

 
   Reply to topic    DELPHI AREA Forum Index -> Delphi Programming
View previous topic :: View next topic  
Author Message
Dave_lopez
Member


Joined: 12 May 2004
Posts: 3
Location: Paris

PostPosted: 15/06/04 08:27    Post subject: [For] A 'For to' which reacts like a 'for downto' Reply with quote

Hi everybody,

I got a this extract of code which uses a for:

Code:
For Cpt:=8 to 128 do
  D[CPT] := S.D[CPT];


What's happening ?
Answer:

Quote:
D[121] := S.D[121];
D[120] := S.D[120];
D[119] := S.D[119];
...
D[2] := S.D[2];
D[1] := S.D[1];

It is driving me crazy ...

Thanx in advance ...

_________________
Destiny exists ...
Back to top
View user's profile
Kambiz
Administrator


Joined: 07 Mar 2003
Posts: 386
Location: Tehran, Iran

PostPosted: 15/06/04 09:17    Post subject: Reply with quote

The downward for loop is faster than the upward one. Because of that, when direction of the for loop variable doesn't affect the result, the compiler optimizes the code and generates the downward loop.
Back to top
View user's profile Send e-mail Visit poster's website
Display posts from previous:   
   Reply to topic    DELPHI AREA Forum Index -> Delphi Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB 2.0.6 © 2001, 2002 phpBB Group