A5下载文章资讯

分类分类

Lua math.fmod使用时的小数问题

2015-06-29 14:49作者:zhao

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

展开全部

相关

说两句网友评论
    我要跟贴
    取消