您的位置:首页 > 编程语言 > Lua

lua math.fmod使用注意小数问题

2015-05-25 17:24 246 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: