模块 math

require "math"

公开 API

API实现说明
math.randommath_random随机数:无参返回 [0,1) 浮点,一个整参返回 [1,m],两个返回 [m,n] 整数
math.randomseedmath_randomseed设置随机种子,并可选(启用则)返回随机数
math.absmath_abs返回 x 的绝对值
math.acosmath_acos返回 x 的反余弦(弧度)
math.asinmath_asin返回 x 的反正弦(弧度)
math.atanmath_atan返回 x 的反正切;两参形式返回 atan(y/x)
math.ceilmath_ceil返回不小于 x 的最小整数
math.cosmath_cos返回 x 的余弦
math.degmath_deg弧度转角度
math.expmath_exp返回 e^x
math.tointegermath_toint将值转换为整数,无法转换返回 nil
math.floormath_floor返回不大于 x 的最大整数
math.fmodmath_fmod返回 x 对 y 取模(浮点)
math.frexpmath_frexp将 x 分解为尾数 m 与指数 e,返回 m 和 e
math.ultmath_ult返回布尔:m
math.ldexpmath_ldexp返回 m * 2^e
math.logmath_log返回 x 的自然对数;带 base 时为以 base 为底
math.maxmath_max返回参数中的最大值
math.minmath_min返回参数中的最小值
math.modfmath_modf返回 x 的整数部分与小数部分
math.radmath_rad角度转弧度
math.sinmath_sin返回 x 的正弦
math.sqrtmath_sqrt返回 x 的平方根
math.tanmath_tan返回 x 的正切
math.typemath_type返回数值内部表示类型:'integer'/'float'
math.atan2math_atan返回 atan(y/x)(兼容旧接口)
math.coshmath_cosh双曲余弦
math.sinhmath_sinh双曲正弦
math.tanhmath_tanh双曲正切
math.powmath_pow返回 x^y
math.log10math_log10返回以 10 为底的 x 对数
math.randomNULL随机数:无参返回 [0,1) 浮点,一个整参返回 [1,m],两个返回 [m,n] 整数
math.randomseedNULL设置随机种子,并可选(启用则)返回随机数
math.piNULL圆周率 π 常量
math.hugeNULL最大浮点值(math.huge = +inf)
math.maxintegerNULL最大整数常量
math.minintegerNULL最小整数常量
← 返回模块索引