LSL Operators

From Second Life Wiki
Revision as of 16:28, 16 February 2007 by Anthony Reisman (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Operators are used to cause an operation (or mathematical action) to be performed on two operands. The easy and common example is 1 + 2 where 1 and 2 are operands, and the + is the operator.

This concept can be extended much further with LSL since operands can be variables with the special case of the assignment operators requiring that the left hand side be a variable.

Operator Description Usage Example
() [] . Parenthesis, Brackets, and Dot do this second (do this first)
! ~ ++ -- NOT, One's Compliment, Increment, Decrement counter++;
* / % Multiply, Divide, Modulus rollover = (count + 1)%5;
+ - Addition and Subtraction one = 3 - 2;
<< >> Left Shift, Right Shift eight = 4 << 1;
< <= > >= Less Than, Less Than Or Equal To,

Greater Than, Greater Than or Equal To

isFalse = (6 <= 4);
==  != Comparison Equal, Comparison Not Equal isFalse = ("this" == "that");
& Bitwise AND zero = 4 & 6;

four = 4 & 4;

^ Bitwise XOR zero = 4 ^ 4;

six = 4 ^ 2;

| Bitwise OR 4;

six = 4 | 2;

&& Comparison AND isFalse = (FALSE && TRUE);
|| Comparison OR TRUE);
= += -= *= /= %= Assignment four = 4;