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 on
Listing 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 { ...
Get Pro TypeScript now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.