20.5. Bitwise Operators
C++ provides extensive bit-manipulation capabilities for getting down to the so-called “bits-and-bytes” level. Operating systems, test-equipment software, networking software and many other kinds of software require that you communicate “directly with the hardware.” We introduce each of the bitwise operators, and we discuss how to save memory by using bit fields.
All data is represented internally by computers as sequences of bits. Each bit can assume the value
0 or the value
1. On most systems, a sequence of eight bits, each of which forms a byte—the standard storage unit for a variable of type
char. Other data types are stored in larger numbers of bytes. Bitwise operators are used to manipulate the bits of integral ...