
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

bottom bits disappear...
if unsigned, right shift in zeros
unsigned char a = 0x55;
unsigned char b = 0x0f;
remember hexadecimal?
Bit-wise Logical Operators (in C, C++, Java, many other languages)
unsigned char c = a | b;
unsigned char d = a & b;
unsigned char e = a ^ b;
Shifting (in C, C++, Java, many other languages)
unsigned char g = f >> 2;
top bits disappear...
unsigned char f = b << 5; always left shift in zeros
bottom bits disappear...
if signed, sign extend MSB
unsigned char i = h >> 2;
signed char h = f;
(bit-wise OR) (bit-wise AND)
(bit-wise XOR)
(left shift)
(right shift logical)
(right shift arithmetic)
unsigned char n = ~a;
(bit-wise NOT)
Note: x >> 1 not the same as x/2 for negative numbers; compare (-3)>>1 with (-3)/