Mikroelektronika MIKROE-350 Fiche De Données

Page de 526
Bitwise Shift Operators
The binary operators 
<<
and 
>>
move the bits of the left operand by a number of
positions specified by the right operand, to the left or right, respectively. Right
operand has to be positive and less than 255.
With shift left (
<<
), left most bits are discarded, and “new” bits on the right are
assigned zeroes. Thus, shifting unsigned operand to the left by n positions is equiv-
alent to multiplying it by 2n if all discarded bits are zero. This is also true for signed
operands if all discarded bits are equal to the sign bit.
With shift right (
>>
), right most bits are discarded, and the “freed” bits on the left are
assigned zeroes (in case of unsigned operand) or the value of the sign bit (in case
of signed operand). Shifting operand to the right by 
n
positions is equivalent to divid-
ing it by 2
n
.
BOOLEAN OPERATORS
Although mikroBasic PRO for AVR does not support 
boolean
type, you have
Boolean operators at your disposal for building complex conditional expressions.
These operators conform to standard Boolean logic and return either 
TRUE
(all ones)
or 
FALSE
(zero):
Boolean operators associate from left to right. Negation operator 
not
associates
from right to left.
150
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Language Reference
mikroBasic PRO for AVR
CHAPTER 5
Operator
Operation
and
logical AND
or
logical OR
xor
logical exclusive OR (XOR)
not
logical negation