August 2014
Intermediate to advanced
248 pages
6h 11m
English
APPENDIX 3
![]()
Bitwise Flags
As described in Chapter 1, you can use an enumeration to define bit flags. Bit flags allow a series of items to be selected or deselected by switching individual bits in a sequence on and off. To ensure that each value in an enumeration relates to a single bit, the numbering must follow the binary sequence whereby each value is a power of two, for example
1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, and so onListing A3-1 is a copy of the example from Chapter 1 and shows bit flags in action. Appendix 3 describes bit flags and bitwise operations in more detail.
Listing A3-1. Flags
enum DiscFlags { ...Read now
Unlock full access