Syntax[]
llAbs(integer val); integer var = llAbs(integer val);
Calculates and returns the absolute value of val passed as argument.
Parameters
- integer val
- any integer value or integer variable, except -2147483648
Returns integer
- returns the absolute value of the first argument
Example
This example will always say the text, as the argument -4 and the argument 4 return both the same value, which is their absolute value 4.
default { state_entry() { if (llAbs(-4) == llAbs(4)) { llSay(PUBLIC_CHANNEL, "The absolute value of -4 is equal with the absolute value of 4."); } } }
Remarks
This function is used, to receive the absolute value of an integer value.
The absolute value of an integer is it's positive represantation. So in simple words:
- The absolute value of every positive integer value is the same value.
- The absolute value of every negative integer value is the value without the negative sign.
Notes
This function will return always a positive value, as absolute values are always positive.
Only exception to this rule is the value -2147483648, which is the lowest negative value that can be represented within the integer range, but the value 2147483648 can't be returned as result, because the highest positive value that can be represented within the integer range is 2147483647. In this case the function will return the wrong value -2147483648.
Related Functions
- llFabs() - returns the absolute value for a float
Platforms
SecondLife (agni), Secondlife (aditi), OpenSimulator
See also[]
- Math category
- llAbs - Function reference at SecondLife LSL Wiki
- llAbs - Function reference at lslwiki.net