Mikroelektronika MIKROE-350 データシート

ページ / 526
BITWISE OPERATORS
Use the bitwise operators to modify the individual bits of numerical operands.
Bitwise operators associate from left to right. The only exception is the bitwise com-
plement operator not which associates from right to left.
Bitwise Operators Overview
Logical Operations on Bit Level
The bitwise operators 
and, or,
and 
xor
perform logical operations on the appro-
priate pairs of bits of their operands. The operator 
not
complements each bit of its
operand. For example:
148
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Language Reference
mikroBasic PRO for AVR
CHAPTER 5
Operator
Operation
and
bitwise AND; compares pairs of bits and generates a 1 result if both
bits are 1, otherwise it returns 0
or
bitwise (inclusive) OR; compares pairs of bits and generates a 1 result
if either or both bits are 1, otherwise it returns 0
xor
bitwise exclusive OR (XOR); compares pairs of bits and generates a 1
result if the bits are complementary, otherwise it returns 0
not
bitwise complement (unary); inverts each bit
<<
bitwise shift left; moves the bits to the left, it discards the far left bit
and assigns 0 to the right most bit.
>>
bitwise shift right; moves the bits to the right, discards the far right bit
and if unsigned assigns 0 to the left most bit, otherwise sign extends
and 0
1
0
0
0
1
0
1
or
0
1
0
0
1
1
1
1
xor
0
1
0
0
1
1
1
0
not
0
1
1
0