C examples for Operator:Bit Operator
Suppose you declare the following variables:
#include <stdio.h> int main(void) { /* w ww . ja v a2s . c o m*/ int x = 13; int y = 6; int z = x & y; // AND corresponding bits of x and y printf("%d",z); return 0; }
After the third statement, z will have the value 4 (binary 100).
This is because the corresponding bits in x and y are combined as follows:
x 0 0 0 0 1 1 0 1 y 0 0 0 0 0 1 1 0 x & y 0 0 0 0 0 1 0 0