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