A bit shift example
#include <stdio.h>
int main(void)
{
unsigned int i;
int j;
i = 1;
/* left shift i by 1, which is same as a multiply by 2 */
for(j = 0; j < 6; j++) {
i = i << 1;
printf("Left shift %d: %d\n", j, i);
}
/* right shift i by 1, which is same as a division by 2 */
for(j = 0; j < 4; j++) {
i = i >> 1;
printf("Right shift %d: %d\n", j, i);
}
return 0;
}
Related examples in the same category