LlAbs
From OpenSimulator
(Difference between revisions)
CodyCooper (Talk | contribs) |
CodyCooper (Talk | contribs) |
||
| Line 1: | Line 1: | ||
| − | {{ | + | {{lslfunc |
|func=llAbs | |func=llAbs | ||
|func_id=6|func_sleep=0.0|func_energy=10.0 | |func_id=6|func_sleep=0.0|func_energy=10.0 | ||
Revision as of 10:28, 28 January 2019
Summary
Function: integer llAbs( integer val );Returns Template:Integer that is the positive version of val.
| • integer | val | – | Any integer value |
Caveats
- The llAbs of -2147483648 is -2147483648. This is because the positive integer 2147483648 is outside the range of allowed LSL Template:LSLGC.
Examples
<lsl> default {
state_entry()
{
// PUBLIC_CHANNEL has the integer value 0
// returns: "The absolute value of -4 is: 4"
llSay(PUBLIC_CHANNEL, "The absolute value of -4 is: "+(string)llAbs(-4) );
}
} </lsl> <lsl> // Here's a more elaborate example.
ShowAbsolute(integer inputInteger) {
string output = "llAbs(" + (string)inputInteger + ") --> " + (string)llAbs(inputInteger);
llSay(PUBLIC_CHANNEL, output);
}
default {
state_entry()
{
ShowAbsolute(-3);
ShowAbsolute(5);
ShowAbsolute(-20);
ShowAbsolute(0);
}
}
// Here's the output produced by the more elaborate example: // // Test Object: llAbs(-3) --> 3 // Test Object: llAbs(5) --> 5 // Test Object: llAbs(-20) --> 20 // Test Object: llAbs(0) --> 0
</lsl>