~ (bitwise NOT) 251
Description
Operator (bitwise compound assignment); assigns expression1 the value of expression1 |
expression2
. For example, the following two statements are the same:
x |= y;
x = x | y;
Example
The following example uses the |= operator:
// 15 decimal = 1111 binary
x = 15;
// 9 decimal = 1001 binary
y = 9;
trace(x |= y);
// 1111 |= 1001
// returns 15 decimal (= 1111 binary)
See also
| (bitwise OR)
~ (bitwise NOT)
Availability
Flash Player 5.
Usage
~ expression
Parameters
expression
A number.
Returns
None.
Description
Operator (bitwise); converts the expression to a 32-bit unsigned integer, then inverts the bits. A
bitwise NOT operation changes the sign of a number and subtracts 1.
Example
The following example shows a bitwise NOT operation performed on a variable.
a = 0;
trace ("when a = 0, ~a = "+~a);
// when a = 0, ~a = -1
a = 1;
trace ("when a = 1, ~a = "+~a);
// when a = 0, ~a = -2
// therefore, ~0=-1 and ~1=-2