
Basic Data Operation

This is a basic data operation. It represents a fundamental action on a basic data type.
You may see other such operations in the Basic Data Operations category, or:


Integer Operations
Arithmetic |
Comparison
Boolean Operations
Bitwise |
Logical
String Operations
Concatenation |
Interpolation |
Comparison |
Matching
Memory Operations
Pointers & references |
Addresses




Task

Write a routine to perform a bitwise AND, OR, and XOR on two integers, a bitwise NOT on the first integer, a left shift, right shift, right arithmetic shift, left rotate, and right rotate.

All shifts and rotates should be done on the first integer with a shift/rotate amount of the second integer.

If any operation is not available in your language, note it.




Text(0, "A and B = ");  HexOut(0, A and B);  CrLf(0);   \alternate symbol: &
Text(0, "A or B = ");   HexOut(0, A or B);   CrLf(0);   \alternate symbol: !
Text(0, "A xor B = ");  HexOut(0, A xor B);  CrLf(0);   \alternate symbol: |
Text(0, "not A = ");    HexOut(0, not A);    CrLf(0);   \alternate symbol: ~
Text(0, "A << B = ");   HexOut(0, A << B);   CrLf(0);
Text(0, "A >> B logical = ");  HexOut(0, A >> B);  CrLf(0);
Text(0, "A >> B arithmetic = ");  HexOut(0, A ->> B);  CrLf(0);
 
\Rotate operations must be done by calling a function such as:
func ROR(A, B); int A, B; return A>>B ! A<<(32-B);
 
Text(0, "A ror B = ");  HexOut(0, ROR(A,B));  CrLf(0);