[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
<<                       Bitwise Shift Left

 exp1 << exp2            Bitwise shift left
 exp1                    any integer value
 exp2                    any integer value; treated as unsigned

    The << operator returns exp1 shifted to the left by exp2 bits, with
    the vacated right-hand bits filled  with zeros.  Expression results  are
    converted to integers prior to performing the shift.  For example:

           j = 9353;            # j == 0x0F71 == 0000111101110001 (base 2)
           i = j << 4;          # i == 0xF710 == 1111011100010000 (base 2)

>>                       Bitwise Shift Right

 exp1 >> exp2            bitwise shift right
 exp1                    any integer value
 exp2                    any integer value; treated as unsigned

    The >> operator returns  exp1 shifted to the  right by exp2 bits,  with
    the vacated left-hand  bits filled with  zeros.  Expression  results are
    converted to integers prior to performing the shift.  For example:

           j = 9353;            # j == 0x0F71 == 0000111101110001 (base 2)
           i = j >> 4;          # i == 0xF710 == 0000000011110111 (base 2)

This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson