previous | start | next

Left shift



int x = 0x1000801F;
In binary x's value:  0001 0000 0000 0000 1000 0000 0001 1111
          ---------- ----------------------------------------
          x << 3   :  1000 0000 0000 0100 0000 0000 1111 1000

In hex the value of x << 3 is: 0x800400F8

The left shift operation, x << n is performed by starting with a copy
of the bits of x, then shifting them left n bits. The leftmost n bits
have nowhere to go and are discarded. The rightmost n bits are filled
with 0's.  



previous | start | next