Table of Contents

Start Functions Events Constants Types Language Articles

Function: llAbs

integer llAbs(integer ival)

Return the absolute value of the parameter (for integers).

Parameters

ival

Any integer value (can be negative)

Return value

It returns an integer that is the absolute value of ival, that is, the value with any negative sign removed.

More rigorously, the result will be the same as ival if ival is positive or zero, and -ival if it is negative.

Notes

Short examples

integer AbsInt;
AbsInt = llAbs(-3);    // sets AbsInt to 3
AbsInt = llAbs(-45);   // sets AbsInt to 45
AbsInt = llAbs(0);     // sets AbsInt to 0
AbsInt = llAbs(45);    // sets AbsInt to 45
Absint = llAbs(AbsInt - 50); // sets AbsInt to 5 (see explanation below)

The last example assumes that AbsInt was 45 due to the previous line. 45 - 50 equals -5, and llAbs(-5) equals 5.

See also