×
A new build of Corona SDK is now available to subscribers. Not a subscriber? Subscribe now.
CoronaSDK 2014.2419 | Released: 28 Aug 2014, 8:06am | What's New | Download Now

math.abs()

Description:

Returns the absolute value (magnitude) of a number.

Syntax:

math.abs (x)

Example:

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

Parameters:

x
A number.

Returns:

A positive number.

Remarks:
Supported on operating systems and platforms for build numbers shown:
  • Mac OS X:
    Corona SDK 1.0
  • Windows:
    Corona SDK 2.0
  • iOS:
    Corona SDK 1.0
  • Android:
    Corona SDK 2.0