LlAbs
From OpenSimulator
(Difference between revisions)
CodyCooper (Talk | contribs) |
CodyCooper (Talk | contribs) |
||
Line 14: | Line 14: | ||
|caveats=*The llAbs of -2147483648 is -2147483648. This is because the positive integer 2147483648 is outside the range of allowed LSL {{LSLGC|Integer|integer values}}. | |caveats=*The llAbs of -2147483648 is -2147483648. This is because the positive integer 2147483648 is outside the range of allowed LSL {{LSLGC|Integer|integer values}}. | ||
|examples= | |examples= | ||
− | <source> | + | <source lang="lsl"> |
default | default | ||
{ | { | ||
Line 25: | Line 25: | ||
} | } | ||
</source> | </source> | ||
− | <source> | + | <source lang="lsl"> |
// Here's a more elaborate example. | // Here's a more elaborate example. | ||
Latest revision as of 10:31, 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
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) ); } }
// 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