首页 > 代码库 > Lua 笔记--数学库
Lua 笔记--数学库
一、数学库
--获取系统时间 print(os.time()) --调用math.sin函数 print(math.sin(30)) --[[将角度转换成弧度 math.deg(x) --将弧度转换成角度 math.rad(x) ]] --[[指数函数、对数函数 math.exp(x) math.log(x) ]] --取整函数 local n = 3.14 print(math.floor(n)) --向下取整 print(math.ceil(n)) --向上取整 --取最大值、最小值 print(math.max(3, 5, 2, 1)) print(math.min(3, 5, 2, 1)) --生成随机数 print(math.random()) --0~1之间的随机数 print(math.random(1)) --1~6之间的随机数 print(math.random(1, 4)) --1~4之间的随机数 math.randomseed(os.time())
二、table库
Lua 笔记--数学库
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。