5:
1
0
1
~5:
0
1
0
Therefore: ~
5 = (Binary) 010 = (Decimal) 2
Realize that the bitwise not is performed on a 32-bit value, e.g.
~0
converts to a 32-bit value with all bits
in the integer set to 1. To get just the bits you want, you should AND the result with the bits of interest,
e.g.
~5 & 7
.
Range (in) Operator
The ‘in’ operator compares a numerical value or Variable against a range Variable. The resultant type is
an integer value of either 0 or 1. If the value is within the range, 1 is returned; otherwise, 0 is returned.
For example, assume Count has a value of 15, Range10 has a value of 1 to 10, and Range20 has a value
of 1 to 20
This expression...
... resolves to this value.
Count in Range10
0
Count in Range20
1
Assignment (=) Operator
The ‘=’ operator stores a value (R-Value) into a Variable (L-Value). The value on the left of the
assignment operator is the L-Value. The result of the assignment is an R-value, and cannot be used in
another assignment, though it can be used as the result of an expression.
For example:
This expression...
... resolves to this value.
3=4
Illegal (L-Value not a
Variable)
MyCounter=1
1 (also stores 1 into
the MyCounter Variable)
5==(MyCounter=1)
0 (stores 1 into
MyCounter as well)
Addition Assignment (+=) Operator
The ‘+=’ operator is used to append one string to another, or to add two integer values together.
Adding a number to a string will produce a string with the number (as text) appended to the end. Adding
a string to a number results in just the number (unless the string contains a value that can be converted to
a number).
For example, assuming
MyNumber
has an integer value of
4
, and
MyString
has a value of
“Hello”
: