Electron microscopy
 
Bit-Fields in C++
- Practical Electron Microscopy and Database -
- An Online Book -
Microanalysis | EM Book                                                                                   http://www.globalsino.com/EM/        


=================================================================================

 

Unlike many other computer languages, C++ has a built-in method to access a single bit within a byte. Bit access is achieved by using a bit-field. Bit-fields can be useful for a number of reasons, for instance:
        i) If storage is limited, several Boolean values can be stored in one byte.
        ii) Certain device interfaces transmit information encoded into bits within one byte.
        ii) Certain encryption routines need to access the bits within a byte.

All of these functions above can be performed using the bitwise operators; however, a bit-field can add more transparency and readability to the program. The method, which C++ uses to access bits, is based on the structure. A bit-field, in fact, is just a special type of structure member that defines its length in bits.

 

 

 

 

 

 

=================================================================================