The following operators are available in expressions:

= |
Assigns the result right of the '=' to the variable left of the '='. |

+-*/ |
The usual mathematical operators. * and / have a higher priority than + and -. |

% |
Modulo operator, the integer remainder of a division. |

| |
Bitwise OR, can be used to set certains bits in a variable. |

^ |
Bitwise exclusive OR, can be used to toggle certain bits in a variable. |

~ | LC Bitwise invert, toggles all bits of a variable. |

& |
Bitwise AND, can be used to reset certains bits in a variable. |

>> |
Bitwise right shift, can be used to divide a positive integer value by 2. |

<< |
Bitwise left shift, can be used to multiply a positive integer value by 2. |

() |
Brackets, for defining the priority of mathematical operations. Always use brackets when priority matters! |

x = (a + 1) * b / c; z = 10; x = x >> 2;// divides x by 4x = x << 3;// multiplies x by 8x = fraction(x) << 10;// copies the fractional part of x (10 bits) into the integer partmy.tilt = asin(3*x + 0.5); my.z += 2;// increase the entities' Z position by 2 quantsmy.z += 2*time_step;// move Z by a time-corrected speedmy.event = react_function;// Sets the entities' event functionon_s = save_function;// Assigns a function to the [S] key

+= |
Adds the result right of the operator to the variable left of the operator. |

-= |
Subtracts the result right of the operator from the variable left of the operator. |

*= |
Multiplies the variable left of the operator by the result right of the operator. |

/= |
Divides the variable left of the operator by the result right of the operator. |

%= |
LC Sets the variable left of the operator to the remainder of the division by the result right of the operator. |

|= | LC Bitwise OR's the the result right of the operator and the variable left of the operator. |

&= | LC Bitwise AND's the the result right of the operator and the variable left of the operator. |

^= | LC Bitwise excöusive OR's the the result right of the operator and the variable left of the operator. |

>>= | LC Bitwise right shift the variable left of the operator by the result right of the operator. |

<<= | LC Bitwise left shift the variable left of the operator by the result right of the operator. |

x = x + 1;// add 1 to xx += 1;// add 1 to xx++;// add 1 to x (lite-C only)

- When using
**var**variables, bear in mind that the fixed point arithmetic rounds all factors or intermediate values below 0.001 down to zero. Also the maximum and minimum values of 999999.999 and -999999.999 must not be exceeded. This applies to intermediate results within an expression also - so a little care has to be taken using mathematical expressions. Invalid operations - a result exceeding the maximum values, a division by zero, a square root of a negative number etc. - will cause wrong results or error messages. -
For setting and resetting flags through the
**&**or**|**operators, use**long**or**int**variables. - !!
The precedence of comparison and expression operators follows the C/C++ standard. Use parentheses in case of doubt. For instance, the expressions
**(x & y == z)**and**((x & y) == z)**give different results because the**&**operator has lower precedence than the**==**operator.

See also:

Functions, Variables, Pointers, Comparisons► latest version online