Unofficial LSL Reference

[[functions:llabs]]


Unofficial LSL reference

User Tools

Login

You are currently not logged in! Enter your authentication credentials below to log in. You need to have cookies enabled to log in.

Login

Forgotten your password? Get a new one: Set new password

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

  • To determine the absolute value of a float, use llFabs.
  • As a special case, the absolute value of -2,147,483,648 (-231, the lowest integer LSL supports) is returned by this function as -2,147,483,648 because the positive integer 2,147,483,648 is outside the range of a LSL integer.

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

  • llFabs takes the absolute value of a float.
  • Other math functions