Advertisement
math230

Bit shifting in C - logical vs arithmetic shifts

Mar 18th, 2020
563
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.32 KB | None | 0 0
  1.  
  2. #include <stdio.h>
  3. int main ()
  4. {
  5.   unsigned  int x = 0xf0001111;
  6.             int y = 0xf0001111;
  7.   printf("%08x \n", x);
  8.  
  9.   printf("shifting as unsigned value: %08x \n", x >> 4);
  10.   //int y = 0xf0001111;
  11.   printf("shifting as SIGNED value:   %08x \n", y >> 4);
  12.  
  13.   return 0;
  14. }
  15.  
  16.  
  17.  
  18. /*
  19. f0001111
  20. 0f000111
  21. ff000111
  22. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement