Atom

math.abs()

Computes the magnitude.

Signature

math.abs(x)

Parameters

One number.

Returns

f64.

Behavior

Converts x to binary64. Large integers can round.

Errors

Requires a number.

Example

Atom
use math
assert(math.abs(-3) == 3.0)

Find the size of an offset

A negative offset still has a positive distance from zero.

Atom
use math
print(math.abs(-4))
Output
4

The result is a floating-point value with magnitude 4.