The
bitwise AND
operation
The
bitwise XOR
operation
The
bitwise NOT
operation
The
bitwise operators in C
- The bitwise operators
of C
(also
available
in Java):
Operator symbol
|
Meaning
|
&
|
Bitwise AND
|
|
|
Bitwise OR
|
^
|
Bitwise XOR
|
~
|
Bitwise NOT
|
- Sample C program:
int main( int argc, char* argv[] )
{
char a = 20; // 00010100 ==> 16 + 4 = 20
char b = 15; // 00001111 ==> 8 + 4 + 2 + 1 = 15
char c;
c = a & b; // c = 00000100
c = a | b; // c = 00011111
c = a ^ b; // c = 00011011
c = ~a; // c = 11101011
}
|
|
DEMO:
demo/C/set1/bit-op1.c
❮
❯