Symbols > ~ (bitwise NOT) |
~ (bitwise NOT)
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