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

## LSL Wiki : Binary

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl338.us.archive.org

## 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: +
 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 , and B a value of , and add them together, you get . rotation rotation A rotation, representing the values of the four component floats of each rotation added together, seperately. For example, if you give A a value of , and B a value of , and add them together, you get . 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 , 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
Comments [Hide comments/form]
Keknehv, if you don't like the tables, fix them. Don't just add notes to the page bemoaning them, do something about it.
-- CatherineOmega (2005-07-13 19:06:29)
The problem is, I the only way I see to fix them is to remove them. They're completely useless.

I just wanted someone else's opinion before I remove this many pages of tables.
-- KeknehvPsaltery (2005-07-13 21:15:56)
The informational content of the tables are highly usable. I'll have a go at restructuring them for readability.
-- StefanNilsson (2005-07-14 08:34:06)
In playing about with some 4d stuff, I've been using rotations as 4d vectors... and it escapes me why addition of rotations is implemented but multiplication by a float isn't. I can't think of any valid use for adding two rotations (unless one is using them as a 4d vector). Multiplying a rotation by a scalar is at least useful in renormalising them when they become non unit due to float errors. Oh, and yes, these tables are very useful.
-- SeifertSurface (2006-03-13 01:45:54)
Shouldn't <= and >= be in the table at the top?
-- SuezanneCBaskerville (2006-11-18 02:31:34)
Done
-- AakanaarLaSalle (2006-11-18 23:20:15)
Attach a comment to this page: