lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello All,
i am a lua user although not a real programmer so probably my questions
will be really basics, and i apologies for this.

Anyway my question is: why this two iterators are different?

iter = 0
for x=0.0, 1.0, 0.1 do
  iter = iter + 1
end
print(iter) --> 11

iter = 0
for x=1.0, 2.0, 0.1 do
  iter = iter + 1
end
print(iter) --> 10

the first include last value (1.0), while the second not.

the first example work like when using any integer step
(i.e. for i=start, end, integer).

I would like to understand why that happens.

Thanks in advance,
ciao,
francesco.