April 2022
Intermediate to advanced
1012 pages
38h 1m
English
This appendix discusses the manipulation of bits in integer data. We discuss the bitwise operators that allow you to access and manipulate the individual bits in bytes of data. We also present bit fields—structures that can be used to specify the exact number of bits a variable occupies in memory.
C++ provides extensive bit-manipulation capabilities for getting down to the “bits-and-bytes” hardware level. Bit manipulation is typically used in programs that need to communicate directly with hardware. It’s also used in encryption data compression and other algorithms.1 We introduce each bitwise operator and discuss how to save memory by using bit fields.
1. “Bit manipulation.” Wikipedia. Wikimedia Foundation. ...