Compound Assignment Operators

Language Element Short Description
Addition Assignment Operator (+=) Adds the value of an expression to the value of a variable and assigns the result to the variable.
Bitwise AND Assignment Operator (&=) Performs a bitwise AND on the value of a variable and the value of an expression and assigns the result to the variable.
Bitwise OR Assignment Operator (|=) Performs a bitwise OR on the value of a variable and the value of an expression and assigns the result to the variable.
Bitwise XOR Assignment Operator (^=) Performs a bitwise exclusive OR on a variable and an expression and assigns the result to the variable.
Division Assignment Operator (/=) Performs a division on the value of a variable and the value of an expression and assigns the result to the variable.
Left Shift Assignment Operator (<<=) Left shifts the value of a variable by the number of bits specified in the value of an expression and assigns the result to the variable.
Modulus Assignment Operator (%=) Divides the value of a variable by the value of an expression, and assigns the remainder to the variable.
Multiplication Assignment Operator (*=) Performs a multiplication on the value of a variable and the value of an expression and assigns the result to the variable.
Right Shift Assignment Operator (>>=) Right shifts the value of a variable by the number of bits specified in the value of an expression, maintaining the sign, and assigns the result to the variable.
Subtraction Assignment Operator (-=) Performs a subraction on the value of a variable and the value of an expression and assigns the result to the variable.
Unsigned Right Shift Assignment Operator (>>>=) Right shifts the value of a variable by the number of bits specified in the value of an expression, without maintaining sign, and assigns the result to the variable.

Addition Assignment Operator (+=)

Adds the value of an expression to the value of a variable and assigns the result to the variable.
result += expression

Arguments

result
Any variable
expression
Any expression
Using this operator is exactly the same as specifying: result = result + expression

Bitwise AND Assignment Operator (&=)

Performs a bitwise AND on the value of a variable and the value of an expression and assigns the result to the variable.
result &= expression

Arguments

result
Any variable.
expression
Any expression
Using this operator is exactly the same as specifying: result = result & expression

Bitwise OR Assignment Operator (|=)

Performs a bitwise OR on the value of a variable and the value of an expression and assigns the result to the variable.
result |= expression

Arguments

result
Any variable
expression
Any expression
Using this operator is exactly the same as specifying: result = result | expression

Bitwise XOR Assignment Operator (^=)

Performs a bitwise exclusive OR on a variable and an expression and assigns the result to the variable.
result ^= expression

Arguments

result
Any variable.
expression
Any expression.
Using the ^= operator is exactly the same as specifying: result = result ^ expression

Division Assignment Operator (/=)

Performs a division on the value of a variable and the value of an expression and assigns the result to the variable.
result /= expression

Arguments

result
Any variable
expression
Any expression
Using this operator is exactly the same as specifying: result = result / expression

Left Shift Assignment Operator (<<=)

Left shifts the value of a variable by the number of bits specified in the value of an expression and assigns the result to the variable.
result <<= expression

Arguments

result
Any variable.
expression
Any expression.
Using the <<= operator is exactly the same as specifying: result = result << expression

Modulus Assignment Operator (%=)

Divides the value of a variable by the value of an expression, and assigns the remainder to the variable.
result %= expression

Arguments

result
Any variable
expression
Any expression
Using the %= operator is exactly the same as specifying: result = result % expression

Multiplication Assignment Operator (*=)

Performs a multiplication on the value of a variable and the value of an expression and assigns the result to the variable.
result *= expression

Arguments

result
Any variable
expression
Any expression
Using this operator is exactly the same as specifying: result = result * expression

Right Shift Assignment Operator (>>=)

Right shifts the value of a variable by the number of bits specified in the value of an expression, maintaining the sign, and assigns the result to the variable.
result >>= expression

Arguments

result
Any variable.
expression
Any expression.
Using the >>= operator is exactly the same as specifying: result = result >> expression

Subtraction Assignment Operator (-=)

Performs a subraction on the value of a variable and the value of an expression and assigns the result to the variable.
result -= expression

Arguments

result
Any variable
expression
Any expression
Using this operator is exactly the same as specifying: result = result - expression

Unsigned Right Shift Assignment Operator (>>>=)

Right shifts the value of a variable by the number of bits specified in the value of an expression, without maintaining sign, and assigns the result to the variable.
result >>>= expression

Arguments

expression
Any expression.
Using the >>>= operator is exactly the same as specifying: result = result >>> expression


Copyright © 1999-2006 VIRT Laboratory. All rights reserved.