## 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.

 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..

Operator: +

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 , and B a value of , and subtract them, you get . rotation rotation A 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 , and B a value of , and subtract them, you get . 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. vector float A vector, whose direction has not changed but magnitude has. 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 , and B, a value of , 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. vector float A vector, whose direction has not changed but magnitude has. vector rotation A 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 rotation A 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