November 2001
Beginner
1128 pages
29h 12m
English
The bitwise operators operate upon the bits of integer values. For example, the left-shift operator moves bits to the left, and the bitwise negation operator turns each one to a zero, and each zero to a one. Altogether, C++ has six such operators: <<, >>, ~, &, |, and ^.
The left-shift operator has the following syntax:
value << shift
Here value is the integer value to be shifted, and shift is the number of bits to shift. For example:
13 << 3
means shift all the bits in the value 13 three places to the left. The vacated places are filled with zeros, and bits shifted past the end are discarded (see Figure E.1).
Because each bit position represents a value twice that ...