Left-Shift Operator

The left-shift operator (<<) shifts the bits of its left operand to the left by the number of bits specified in its right operand. Bits vacated to the right are replaced with 0s; bits shifted off the left are lost. In Fig. 20.11, line 11 assigns variable number1 the value 960 (00000000 00000000 00000011 11000000). The result of left-shifting variable number1 eight bits in the expression number1 << 8 (line 17) is 245760 (00000000 00000011 11000000 00000000).

Get C++11 for Programmers, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.