Bitwise Logical Functions
The following bitwise logical functions are available:
BITNOT(expression)
BITAND(expression1,expression2)
BITNAND(expression1,expression2)
BITOR(expression1,expression2)
BITNOR(expression1,expression2)
BITXOR(expression1,expression2)
BITXNOR(expression1,expression2)
Here each expression is a valid DataBasic expression or any string, substring or value; may be expressed as a variable name, a value, or a string enclosed in quote marks that evaluates to a decimal number (of which only the integer part is used).
Each expression is converted to a hexadecimal number before the logical operator is performed. If one expression is shorter than the other the shorter one is first sign extended to be the same length. There is no limit to the length that can be accommodated.
The operation of these functions is summarised below.
Expression |
Bit string |
---|---|
Expression A |
|
Expression B |
0101 |
Function |
Result |
BITNOT(A) |
|
BITNOT(B) |
|
BITAND(A,B) |
|
BITNAND(A,B) |
|
BITOR(A,B) |
|
BITNOR(A,B) |
|
BITXOR(A,B) |
|
BITXNOR(A,B) |
|
Example
Given the following program:
1 2 IN.H = "78F0" 3 IN.D = IN.H "MCXD" 4 OUT.D = BITNOT(IN.D) 5 OUT.H = OUT.D "MCDX" 6 CRT IN.H, IN.D 7 CRT OUT.H, OUT.D 8
The output will be:
78F0 30960 870F 34575
See also
BITAND function, BITNAND function, BITNOR function, BITNOT function, BITOR function, BITXNOR function, BITXOR function.