LOTUSSCRIPT LANGUAGE


Bitwise Operators
An expression consisting of the bitwise operator Not and a numeric operand evaluates to an Integer or Long value (or to NULL if the operand is NULL). This number is the result of reversing the values of the bits in the binary representation of the operand (one’s complement).

For example:

anInt% = 8
Print Bin$(anInt%)
' Output: 1000
anotherInt% = Not anInt%
Print Bin$(anotherInt%)
' Output: 11111111 11111111 11111111 11110111

An expression consisting of two numeric operands and a bitwise operator evaluates to an Integer or Long value (or to NULL if one of the operands is NULL). The rules that determine the data type of the result of a bitwise operation are:


The results of bitwise operations on two-operand expressions are:
OperatorIf bit n in expr1 isAnd bit n in expr2 is Then bit n in the result is
And0 0 0
0 1 0
1 0 0
1 1 1
Or0 0 0
0 1 1
1 0 1
1 1 1
Xor0 0 0
0 11
1 0 1
1 1 0
Eqv0 0 1
0 1 0
1 0 0
1 1 1
Imp0 0 1
0 1 1
1 0 0
1 1 1
For example:

anInt% = 10
anotherInt% = 5
aDouble# = 2.6
Print Bin$(anInt%)
' Output: 1010
Print Bin$(anotherInt%)
' Output: 101
Print Bin$(aDouble#)
' Output: 11

theResult% = anInt% And anotherInt%
Print Bin$(theResult%)
' Output: 0
theResult% = anInt% And aDouble#
Print Bin$(theResult%)
' Output: 10

theResult% = anInt% Or anotherInt%
Print Bin$(theResult%)
' Output: 1111
theResult% = anInt% Or aDouble#
Print Bin$(theResult%)
' Output: 1011

theResult% = anInt% Xor anotherInt%
Print Bin$(theResult%)
' Output: 1111
theResult% = anInt% Xor aDouble#
Print Bin$(theResult%)
' Output: 1001
theResult% = anInt% Eqv anotherInt%
Print Bin$(theResult%)
' Output: 11111111 11111111 11111111 11110000
theResult% = anInt% Eqv aDouble#
Print Bin$(theResult%)
' Output: 11111111 11111111 11111111 11110110

theResult% = anInt% Imp anotherInt%
Print Bin$(theResult%)
' Output: 11111111 11111111 11111111 11110101
theResult% = anInt% Imp aDouble#
Print Bin$(theResult%)
' Output: 11111111 11111111 11111111 11110111

See Also