Operators - Bitwise
~ (negation), << (left shift), >> (right shift), & (and), | (or), ^ (exclusive or)
e.g. if x = 0011,
y = 1011 (4 bits binary number);
~x = 1100;
x & y = 0010; x | y = 1011;
x ^ y = 1000
x << 2 = 1100 (zero fill)
y >> 2 = 0010 (zero fill)
or = 1110 (sign extend)
if anyNumber & 1
printf(“anyNumber is odd”) ;
Previous slide
Next slide
Back to first slide
View graphic version