FOR Loops with different formats for control variable
Posted: Thu Sep 03, 2015 8:58 am
Hello,
could you please help me to understand why Eviews has a different behaviour running for-next loops if I use different numeric formats for the control variable (i.e. the scalar that guides the loop iterations)?
For example, If I run the following program I get different result for scalars STEST1 and STEST2 (2 vs 3).
I expected to get 3 in both cases but in the first case the loop has only 2 iterations.
'test for loop
!CTR=1
FOR !J=0.1 TO 0.3 STEP 0.1
SCALAR STEST1=!CTR
!CTR=!CTR+1
NEXT
!CTR=1
FOR !J=1 TO 3 STEP 1
SCALAR STEST2=!CTR
!CTR=!CTR+1
NEXT
'end of program
Thanks a lot for you help,
Roberto
could you please help me to understand why Eviews has a different behaviour running for-next loops if I use different numeric formats for the control variable (i.e. the scalar that guides the loop iterations)?
For example, If I run the following program I get different result for scalars STEST1 and STEST2 (2 vs 3).
I expected to get 3 in both cases but in the first case the loop has only 2 iterations.
'test for loop
!CTR=1
FOR !J=0.1 TO 0.3 STEP 0.1
SCALAR STEST1=!CTR
!CTR=!CTR+1
NEXT
!CTR=1
FOR !J=1 TO 3 STEP 1
SCALAR STEST2=!CTR
!CTR=!CTR+1
NEXT
'end of program
Thanks a lot for you help,
Roberto