Binary operators accept two parameters and return a single value. Most binary operators are defined for many different types of input like list, float, vector.
Binary Operators:
Operator | Type | Meaning | Return Value | Effect |
+ | Arithmetic | Addition | Sum of inputs | None |
– | Arithmetic | Subtraction | Subtraction of inputs | None |
* | Arithmetic | Multiplication | Multiplication of inputs | None |
/ | Arithmetic | Division | Division of inputs | None |
% | Arithmetic | modulo (remainder) or vector cross product | Remainder after division | None |
> | Arithmetic | Greater than | TRUE or FALSE | None |
< | Arithmetic | Less than | TRUE or FALSE | None |
>= | Arithmetic | Greater than or Equal to | TRUE or FALSE | None |
<= | Arithmetic | Less than or Equal to | TRUE or FALSE | None |
!= | Logical | Inequality | TRUE or FALSE | None |
== | Logical | Equality | TRUE or FALSE | None |
&& | Logical | AND | TRUE or FALSE | None |
|| | Logical | OR | TRUE or FALSE | None |
& | Bitwise | AND | AND of each bit of inputs | None |
| | Bitwise | OR | OR of each bit of inputs | None |
<< | Bitwise | Left shift | Left shift | None |
>> | Bitwise | Right shift | Right shift | None |
^ | Bitwise | Exclusive OR | XOR of each bit of inputs | None |
Like many other languages, LSL supports combining the assignment operator with binary operators.
Operator | Syntax | Description |
+= | var1 += var2 | Assigns the value var1 + var2 to the variable var1. |
-= | var1 -= var2 | Assigns the value var1 - var2 to the variable var1. |
/= | var1 /= var2 | Assigns the value var1 / var2 to the variable var1. |
*= | var1 *= var2 | Assigns the value var1 * var2 to the variable var1. |
%= | var1 %= var2 | Assigns the value var1 % var2 to the variable var1. |
The following tables can be used to calculate the output given the type of the left and right hand operands (A and B respectively) for each operator. Only possible operations are listed.
Credit to: Lslwiki.net (not working) with changes made for brevity and clarity.