ABL electronic PIC12 Personal Computer User Manual


 
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
complement operator
~ which associates from right to left.
Bitwise Operators Overview
Note: Operator
& can also be the pointer reference operator. Refer to Pointers for
more information.
Bitwise operators
&, |, and ^ perform logical operations on appropriate pairs of
bits of their operands. For example:
0x1234 & 0x5678;
/* equals 0x1230 */
/* because ..
0x1234 : 0001 0010 0011 0100
0x5678 : 0101 0110 0111 1000
---------------------------------
& : 0001 0010 0011 0000
.. that is, 0x1230 */
MikroElektronika:
Development
tools
-
Books
-
Compilers
10 5
page
mikroC
- C Compiler for Microchip PIC microcontrollers
mikroC
making it simple...
Operator Operation Precedence
&
bitwise AND; returns 1 if both bits are 1, oth-
erwise returns 0
9
|
bitwise (inclusive) OR; returns 1 if either or
both bits are 1, otherwise returns 0
9
^
bitwise exclusive OR (XOR); returns 1 if the
bits are complementary, otherwise 0
10
~
bitwise complement (unary); inverts each bit 10
>>
bitwise shift left; moves the bits to the left,
see below
10
<<
bitwise shift right; moves the bits to the right,
see below
10