首页 > Web开发 > 详细

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

时间:2016-02-07 00:41:01      阅读:242      评论:0      收藏:0      [点我收藏+]
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

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

原文:http://www.jb51.net/article/68546.htm

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!