Bitwise Operations

We provide bitwise operations defined on integers. They are not defined for floats or decimals. The bitwise operations work for negative and positive integers including zero. They also work for unbounded integers. The bit pattern that corresponds to an integer can be viewed as infinitely extending to the left, for positive integers and zero by 0’s and for negative integers by 1’s. The bitwise operations then work on the corresponding binary digits:

Examples:
-11	=	  …10101
2 = …010
(-11) \/ 2 --> -9 = …10111
(-11) /\ 2 --> 0 = …0
(-11) >> 2 --> -3 = …101
(-11) << 2 --> -44 = …1010100
\ (-11) --> 10 = …01010

The following bitwise operations are recognized in evaluations:

\ X: [ISO 9.4.5]
If X is an integer then returns the bitwise complement of X.
X /\ Y: [ISO 9.4.3]
If X and Y are both integers then the function returns the bitwise X and Y.
X \/ Y: [ISO 9.4.4]
If X and Y are both integers then the function returns the bitwise X or Y.
xor(X, Y): [TC2 9.4.6]
If X and Y are both integers then the function returns the bitwise exclusive X or Y.
X << Y: [ISO 9.4.2]
If X and Y are both integers then the function returns X shifted by Y places left.
X >> Y: [ISO 9.4.1]
If X and Y are both integers then the function returns X shifted by Y places right.