NXC
Version 1.2.1 r5
|
Once declared, variables may be assigned the value of an expression using the syntax shown in the code sample below.
There are thirteen different assignment operators. The most basic operator, '=', simply assigns the value of the expression to the variable. The other operators modify the variable's value in some other way as shown in the table below.
Operator | Action |
---|---|
= | Set variable to expression |
+= | Add expression to variable |
-= | Subtract expression from variable |
*= | Multiple variable by expression |
/= | Divide variable by expression |
%= | Set variable to remainder after dividing by expression |
&= | Bitwise AND expression into variable |
|= | Bitwise OR expression into variable |
^= | Bitwise exclusive OR into variable |
||= | Set variable to absolute value of expression |
+-= | Set variable to sign (-1,+1,0) of expression |
>>= | Right shift variable by expression |
<<= | Left shift variable by expression |
The code sample below shows a few of the different types of operators that you can use in NXC expressions.