Page 3 of 3

Re: For Next Step

Posted: Sat Mar 24, 2012 2:18 am
by charvista
@Tenaja
This is in fact exactly my idea with the PRECISION n.

Code: Select all

Precision=2
n=12345
Debug n/Pow(10,Precision)
:D

Re: For Next Step

Posted: Sat Mar 24, 2012 7:36 am
by STARGĂ…TE
beautiful, and then we are back at the beginning that it is sufficient to have integers in For:Next :lol:

Code: Select all

Precision=2
For n = 12300 To 12345 Step 15
	Debug n/Pow(10,Precision)
Next
sorry, but I just do not understand the necessity of floats in For:Next loops

Re: For Next Step (with integer variable instead of constant

Posted: Sat Mar 24, 2012 1:17 pm
by charvista
OK Stargate :D
But IdeasVacuum's main request:
The Step of a For Next loop is limited to an integer constant. There are occasions where an integer is required instead of a constant.
is still a good request, because:

Code: Select all

Precision.i=2
A.d=123.00
Z.d=123.45
S.d=1.5

Start.i=A*Pow(10,Precision)
Stop.i =Z*Pow(10,Precision)
Stap.i =S*Pow(10,Precision)

For n = Start To Stop Step Stap
    Debug n/Pow(10,Precision)
Next
The variable Stap should be an integer variable, instead of an integer constant.
So, for IdeasVacuum's request, I still vote a +1

Re: For Next Step

Posted: Sat Mar 24, 2012 4:59 pm
by chris319
so, no For:To:Next with float or doubles!
Add STEP to that list. That's the most elegant solution and easily worked around with WHILE or REPEAT if the calculation involves floats or doubles.