09-13-2024, 12:47 AM
For i = start To fini Step Sgn(fini - start)
Start = 1: Fini = 90
SGN(90 - 1) = +1 'It's a positive number, so what we end up with is:
FOR i = 1 TO 90 STEP 1
Now, swap start and fini
Start = 90: Fini = 1
SGN (1 -90) = SGN (-89) = -1 it's a negative number, so we end up with:
FOR I = 90 TO 1 STEP -1
See the logic here?
Start = 1: Fini = 90
SGN(90 - 1) = +1 'It's a positive number, so what we end up with is:
FOR i = 1 TO 90 STEP 1
Now, swap start and fini
Start = 90: Fini = 1
SGN (1 -90) = SGN (-89) = -1 it's a negative number, so we end up with:
FOR I = 90 TO 1 STEP -1
See the logic here?