lua math.fmod使用注意小數:
--Returns the remainder of the division of x by y.
function math.fmod (x, y) end //取模運算
這里需要注意小數的問題,看下面兩個例子:
1、
local x = math.fmod(15, 4)
print(x)
結果:4
2、
local x = math.fmod(15.3, 4)
print(x)
結果:3.3
3、
local x = math.fmod(15, 4.1)
print(x)
結果:2.7