IHYPRESS.NET > C PROGRAMMING
HOME | ASP | C | HTML/CSS | JAVASCRIPT | MATLAB | PERL | PHP | PYTHON | RUBY
C > 11. Bitwise Operators
 
<
/* The right shift bitwise operator */
#include <stdio.h>
 
int
main (void)
{
    unsigned a=64, b=25, c=1, d=100;

    printf ("%4d >> 1 = %4d (%3x HEX)\n", a, a>>1, a>>1);
    printf ("%4d >> 1 = %4d (%3x HEX)\n", b, b>>1, b>>1);
    printf ("%4d >> 1 = %4d (%3x HEX)\n", c, c>>1, c>>1);
    printf ("%4d >> 1 = %4d (%3x HEX)\n", d, d>>1, d>>1);
    printf ("%4d >> 2 = %4d (%3x HEX)\n", a, a>>2, a>>2);
    printf ("%4d >> 3 = %4d (%3x HEX)\n", b, b>>3, b>>3);
    printf ("%4d >> 4 = %4d (%3x HEX)\n", d, d>>4, d>>4);
    printf ("%4d >> 5 = %4d (%3x HEX)\n", d, d>>5, d>>5);
        
    return(0);
}
Legend: preprocessor directives | variable declarations | main program | helper functions
user-defined structures | comments
  64 >> 1 =   32 ( 20 HEX)
  25 >> 1 =   12 (  c HEX)
   1 >> 1 =    0 (  0 HEX)
 100 >> 1 =   50 ( 32 HEX)
  64 >> 2 =   16 ( 10 HEX)
  25 >> 3 =    3 (  3 HEX)
 100 >> 4 =    6 (  6 HEX)
 100 >> 5 =    3 (  3 HEX)
COPYRIGHT © 2019 IHYPRESS.NET. A DIVISION OF IHY PRESS, KIRKLAND, WA 98083 USA. ALL RIGHTS RESERVED.
SHARE!