Don't click here unless you want to be banned.

LSL Wiki : Binary

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are ec2-204-236-235-245.compute-1.amazonaws.com

Binary


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.

OperatorSyntaxDescription
+= 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..


Operator: +
Left-A Right-B Output
integer integer An integer, representing the arithmetic result of adding A to B.
integer float A float, representing the arithmetic result of adding A to B.
float integer A float, representing the arithmetic result of adding A to B.
float float A float, representing the arithmetic result of adding A to B.
vector vector A vector, representing the values of the three component floats of each vector added together, seperately. For example, if you give A, a value of <a, b, c>, and B a value of <x, y, z>, and add them together, you get <a + x, b + y, c + z>.
rotation rotationA rotation, representing the values of the four component floats of each rotation added together, seperately. For example, if you give A a value of <a, b, c, d>, and B a value of <x, y, z, s>, and add them together, you get <a + x, b + y, c + z, d + s>. This is a meaningless operation, with respect to rotation math.
string string A string, representing the value of B appended onto the end of A. For example, if A had the value "hello", and B had the value "goodbye", adding them together would give a result of "hellogoodbye".
list list A list with all the elements of B, in order, appended onto the end of A.
* list A list, with A prefixed to the list B. The type of A is maintained inside the new list; A can be any type (other then a list).
list * A list, with B appended to the end of list A. The type of B is maintained inside the new list; B can be any type (other then a list).

Operator: -
Left-A Right-B Output
integer integer An integer, representing the arithmetic result of subtracting B from A.
integer float A float, representing the arithmetic result of subtracting B from A.
float integer A float, representing the arithmetic result of subtracting B from A.
float float A float, representing the arithmetic result of subtracting B from A.
vector vector A vector, representing the values of the three component floats of B and A subtracted from each other, seperately. For example, if you give A a value of <a, b, c>, and B a value of <x, y, z>, and subtract them, you get <a - x, b - y, c - z>.
rotation rotationA rotation, representing the values of the four component floats of each rotation subtracted from each other, seperately. For example, if you give A a value of <a, b, c, d>, and B a value of <x, y, z, s>, and subtract them, you get <a - x, b - y, c - z, d - s>. This is a meaningless operation, with respect to rotation math.

Operator: *
Left-A Right-B Output
integer integer An integer, representing the arithmetic result of multiplying A with B.
integer float A float, representing the arithmetic result of multiplying A with B.
float integer A float, representing the arithmetic result of multiplying A with B.
float float A float, representing the arithmetic result of multiplying A with B.
vector integer A vector, whose direction has not changed but magnitude has. <A.x * B, A.y * B, A.z * B>
vector float A vector, whose direction has not changed but magnitude has. <A.x * B, A.y * B, A.z * B>
vector vector A float, representing the sum of the values of the three component floats of each vector multiplied together, separately. For example, if you give A, a value of <a, b, c>, and B, a value of <x, y, z>, and multiply them together, you get ((a * x) + (b * y) + (c * z)). This is known as the dot product of A and B.
vector rotation A vector, representing the vector A rotated the amount of B. The magnitude of the vector is multiplied by the square of the magnitude of the rotation.
rotation rotation A rotation, representing the combination of two rotations; rotation B applied to rotation A.

Operator: /
Left-A Right-B Output
integer integer An integer, representing the arithmetic result of devision of A by B.
integer float A float, representing the arithmetic result of devision of A of B.
float integer A float, representing the arithmetic result of devision of A of B.
float float A float, representing the arithmetic result of devision of A of B.
vector integer A vector, whose direction has not changed but magnitude has. <A.x / B, A.y / B, A.z / B>
vector float A vector, whose direction has not changed but magnitude has. <A.x / B, A.y / B, A.z / B>
vector rotationA vector, representing the vector A rotated the inverse amount of B. The magnitude of the vector is multiplied by the square of the magnitude of the rotation. Another way to think of this is that A is restated in terms of the coordinate axes represented by B.
rotation rotationA rotation, representing the combination of two rotations; the inverse of rotation B applied to rotation A.

Operator: %
Left-A Right-B Output
integer integer The remainder of dividing A by B.
vector vector Vector cross product of A and B

Operators | Unary | Binary | Bitwise | Boolean | Equality | Assignment
There are 6 comments on this page. [Display comments/form]