math.abs()

类型 函数
math.*
返回值 数字
修订 版本 2024.3703
关键词 abs, 绝对值

概述

返回 x 的绝对值(幅度)。

语法

math.abs( x )
x (必需)

数字。一个数字。

示例

local a = math.abs(153)        -- Sets a to 153
local b = math.abs(-15)        -- Sets b to 15
local c = math.abs(12.234)     -- Sets c to 12.234
local d = math.abs(-9.23)      -- Sets d to 9.23