Lua math.fmod使用时的小数问题
2024年05月18日
•
Lua
•
我要评论
lua math.fmod使用注意小数:--returns the remainder of the division of x by y.function math.fmod (x, y) end
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中的解析表达式
使用一个模式这个例子显示了一个建立和使用模式的程序,它非常简单但很完整:模式是简单的一个或多个小写字符并在尾端以(-1)结束的序列。该程序调用match来当作一...
[阅读全文]
-
-
-
版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。
发表评论