加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

lua math库

发布时间:2020-12-14 22:13:48 所属栏目:大数据 来源:网络整理
导读:copy:http://blog.sina.com.cn/s/blog_a53e5daf01012k1h.html atan2、sinh、cosh、tanh这4个应该用不到。 ? 函数名 描述 示例 结果 pi 圆周率 math.pi 3.1415926535898 abs 取绝对值 math.abs(-2012) 2012 ceil 向上取整 math.ceil(9.1) 10 floor 向下取整

copy:http://blog.sina.com.cn/s/blog_a53e5daf01012k1h.html

atan2、sinh、cosh、tanh这4个应该用不到。


?

函数名 描述 示例 结果
pi 圆周率 math.pi 3.1415926535898
abs 取绝对值 math.abs(-2012) 2012
ceil 向上取整 math.ceil(9.1) 10
floor 向下取整 math.floor(9.9) 9
max 取参数最大值 math.max(2,4,6,8) 8
min 取参数最小值 math.min(2,sans-serif; font-size:12px; border-top-width:medium; border-left-width:medium; border-top-style:none; border-left-style:none"> 2
pow 计算x的y次幂 math.pow(2,16) 65536
sqrt 开平方 math.sqrt(65536) 256
mod 取模 math.mod(65535,2) 1
modf 取整数和小数部分 math.modf(20.12) 20???0.12
randomseed 设随机数种子 math.randomseed(os.time()) ?
random 取随机数 math.random(5,90) 5~90
rad 角度转弧度 math.rad(180) deg 弧度转角度 math.deg(math.pi) 180
exp e的x次方 math.exp(4) 54.598150033144
log 计算x的自然对数 math.log(54.598150033144) 4
log10 计算10为底,x的对数 math.log10(1000) 3
frexp 将参数拆成x * (2 ^ y)的形式 math.frexp(160) 0.625????8
ldexp 计算x * (2 ^ y) math.ldexp(0.625,sans-serif; font-size:12px; border-top-width:medium; border-left-width:medium; border-top-style:none; border-left-style:none"> 160
sin 正弦 math.sin(math.rad(30)) 0.5
cos 余弦 math.cos(math.rad(60)) tan 正切 math.tan(math.rad(45)) asin 反正弦 math.deg(math.asin(0.5)) 30
acos 反余弦 math.deg(math.acos(0.5)) 60
atan 反正切 math.deg(math.atan(1)) 45

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读