|
| 12 Jan 2013 11:27 PM |
for i = 1, 10, .3 do print(i) end
This prints 1 - 9.7
But if I do
for i = 1, 10.1, .3 do print(i) end
It prints 1 - 10
Why is this?
|
|
|
| Report Abuse |
|
|
|
| 12 Jan 2013 11:30 PM |
Because the value is not exactly 10. It's ~` 10.000000001, which is NOT 10. So it doesn't print.
Your increment is not exactly .3. It's somewhere between .299999999 and .30000001, but not exactly .3. |
|
|
| Report Abuse |
|
|
| |
|
|
| 13 Jan 2013 12:07 AM |
And, for the first example, it worked because .3 goes into 9 without a remainder. Why 9? Because 10 - 1 is 9.
The second example only printed to 10 because .3 doesn't go into 9.1. |
|
|
| Report Abuse |
|
|