当前位置: 移动技术网 > IT编程>脚本编程>Lua > Lua math.fmod使用时的小数问题

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

2017年12月08日  | 移动技术网IT编程  | 我要评论
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

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网