Compound Operators
Description
Version 8.10 added compound operators.
These are a special assignment statement that applies the operator to the lvalue
that will be assigned.
lvalue+= 1
The statement above will increment the variable, in general a compound operator makes the 2 following statements equivalent.
lvalue op= expr< /EM>
lvalue = lvalue op expr Compound operators include * + - / AND OR XOR >> <<
Operator precedence does NOT change with a compound operator so that
x += a << b ' BAD, as the addition will take precedence over the shift
should not be used, but you should use
x += (a << b)\
Example
\
i +=
1
' increment i< /FONT>
a AND= &Hffff0fff ' mask
bits 12 to 15 of a
b <<=
5
' shift b left by 5 bits
c OR=
&Hf0 ' set bits
4-7 of c
h *=
10
' multiply h by 10
\
See also
\
\