Bit Operation, Examples
#include <stdio.h>
main()
{
int x = 'A';
int y = 2;
short i, j;
printf("%d\n", x >> y);
i = 0x7A4E;
j = ((i>ɴ) & 0x00FF) | (i<ɠ);
printf("%X\n", j);
}
x = 'A' = 6510 = 0…0010000012
x >ɮ = 0…0000100002=1610
i>ɴ = 0x007A
(i>ɴ) & 0x00FF = 0x007A
i<ɠ = 0x4E00
j = 0x007A | 0x4E00 = 0x4E7A
This is program
pg146.c
Previous slide
Next slide
Back to first slide
View graphic version