I've been messing around with numeric for loops (including the use of the step variant), and came across what I thought to be a rather strange result...
For example, if I say something like:
-- From 0-1, increasing i by 0.1 every iteration (i like the look of fractions better than decimal points)
for i = 0,1,1/10 do
print(i)
end
As expected, the code above prints the following:
0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1
However, when working with larger decimal places (i.e, 0.01 and smaller), the loop will end on i - x/step. For example:
-- This time dividing the step into hundreths...
for i = 0,1,1/100 do
print(i)
end
Except this time instead of i starting at 0 and ending on 1, it will start at 0 and end on 0.99. Is there any specific reason for this? And like I said, same goes for all other larger decimal places:
for i = 0,1,1/1000 do print(i) end
0, 0.001, 0.002 ... 0.999
Question
How can I be 100% certain that my for loop will iterate having it's control variable equal my start value, all the way through my end value while using the step variant? (i.e, 0, 1, 1/100 looping 0 - 1 in hundredths) If anyone has some insight on this, I'd really appreciate it.

2 comments
PIL for Lua 5.0 advises against modifying the counting variable in a for loop: http://www.lua.org/pil/4.3.4.html I do not have a copy of PIL for 5.1 so I don't know if the advice still stands
Yeah it advises against it but I've not had any unusual behaviour from doing it in the past (I wanted to skip a loop to a step but it wouldn't do it)