我是 lua 的新手,我正在使用它来自动化模拟程序 femm 中的一些任务。在我的脚本中,我有这种类型的 for 循环:
for i=0.1,0.3,0.1 do print(i) end
问题是它只从 0.1 迭代到 0.2(它没有输入 i=0.3)。我尝试了其他值(例如从 0.1 到 0.4)并且它工作正常。为什么会发生这种奇怪的行为?这是浮点数问题吗?
iteration lua loops for-loop
for-loop ×1
iteration ×1
loops ×1
lua ×1