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

This is an old revision of the document!


Function: llAbs

integer llAbs(integer IntVal)

Take the absolute value of the parameter.

Parameters

IntVal

a positive or negative integer value or the name of an integer variable.

Result

The result will be an integer that is the absolute value of IntVal, that is the value with any negative sign removed.

More rigorously, the result will be the same as IntVal if IntVal is positive or zero, and -IntVal otherwise.

Notes

  • To determine the absolute value of a float, use llFabs.

Short examples

        integer AbsInt;
        AbsInt = llAbs(-45);   // sets AbsInt to 45
        AbsInt = llAbs(0);     // sets AbsInt to 0
        AbsInt = llAbs(45);    // sets AbsInt to 45

Complete examples

llAbs-example.lsl
default
{
    state_entry()
    {
        llOwnerSay((string)llAbs(-3) + ", " + (string)llAbs(5)); // will print: -3, 5
    }
}

See also