命名空間:數學

方法

腹肌

靜止的

abs(num) 回傳數字

數值的絕對值。

範圍

編號

數位

數值。

退貨

non-null number輸入的絕對數值。

例子

math.abs(-1) == 1
math.abs(1) == 1

天花板

靜止的

ceil(num) 回傳規則.Integer

數值的上限。

範圍

編號

數位

數值。

退貨

non-null rules.Integer整數給定值的上限。

例子

math.ceil(2.0) == 2
math.ceil(2.1) == 3
math.ceil(2.7) == 3

地面

靜止的

Floor(num) 回傳規則.Integer

數值的下限。

範圍

編號

數位

數值。

退貨

non-null rules.Integer整數給定值的下限。

例子

math.floor(1.9) == 1
math.floor(2.0) == 2
math.floor(2.7) == 2

是無限的

靜止的

isInfinite(num) 返回rules.Boolean

測試該值是否為±∞。

範圍

編號

數位

數值。

退貨

non-null rules.Boolean若數字為正無窮大或負無窮大則為 true。

例子

math.isInfinite(∞) == true
math.isInfinite(100) == false

為 NaN

靜止的

isNaN(num) 回傳規則.Boolean

測試該值是否為±∞。

範圍

編號

數位

數值。

退貨

non-null rules.Boolean如果值不是數字則為 true。

例子

math.isNaN(NaN) == true
math.isNaN(100) == false

戰俘

靜止的

pow(基數, 指數) 傳回規則.Float

傳回第一個參數的第二個參數次方的值。

範圍

根據

數位

數字基值。

指數

數位

數字指數值。

退貨

non-null rules.Float將第一個參數的值浮點到第二個參數的冪。

例子

math.pow(2, 2) == 4
math.pow(1.5, 2) == 2.25
math.pow(4, 0.5) == 2

圓形的

靜止的

round(num) 傳回規則.Integer

將輸入值舍入為最接近的整數。

範圍

編號

數位

數值。

退貨

non-null rules.Integer最接近給定值的 int。

例子

math.round(1.9) == 2
math.round(2.4) == 2
math.round(2.5) == 3

開方

靜止的

sqrt(num) 回傳規則.Float

輸入值的平方根。

範圍

編號

數位

數值。

退貨

non-null rules.Float輸入值的平方根。

例子

math.sqrt(4) == 2.0
math.sqrt(2.25) == 1.5