信息发布→ 登录 注册 退出

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

发布时间:2026-01-11

点击量:
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  # 小数问题  # 需要注意  # fmod  # math  # Returns  # remainder  # class  # pre  # brush  
在线客服
服务热线

服务热线

4008888355

微信咨询
二维码
返回顶部
×二维码

截屏,微信识别二维码

打开微信

微信号已复制,请打开微信添加咨询详情!