C++ Extensions (cppx) Documentation Internal Version
Main | Namespaces | Classes | NamespaceMembers | ClassMembers | Files

stdxBitManip.h Classes and Functions

Helper functions for doing various bit manipulations including log base 2 and bit field masking.

Functions

Detailed Documentation

Function Documentation

bool isPow2 uint32_t    val
 

Returns true if the given val is a power of two otherwise returns false

uint32_t pow2himasked uint32_t    val,
uint32_t    pow2
 

Masks off high order bits such that the return value is strictly less than the given power of 2. In other words, set the 32-lg(pow2) higher order bits to zero. For example:

 0x0F = 15 = pow2himasked( 0xFF, 16 ) 
 0x1F = 31 = pow2himasked( 0xFF, 32 )
 0x02 = 2 = pow2himasked( 0xF2, 16 )
 0x12 = 18 = pow2himasked( 0xF2, 32 )

uint32_t pow2lomasked uint32_t    val,
uint32_t    pow2
 

Masks off low order bits. Set the lg(pow2) low order bits equal to zero. For example:

 0xF0 = pow2lomasked( 0xFF, 16 ) 
 0xE0 = pow2lomasked( 0xFF, 32 )
 0xF0 = pow2lomasked( 0xF2, 16 )
 0xE0 = pow2lomasked( 0xF2, 32 )

uint32_t pow2roundUp uint32_t    val
 

Round up to the nearest power of two. If the given val is already a power of two then do nothing.

uint32_t lg uint32_t    val
 

Return the log base two of the given value. This function assumes the input is a power of two.

uint32_t createFieldMask uint32_t    sizeInBits,
uint32_t    shift
 

Creates a bit mask - a consecutive sequence of ones suitable for anding with a bit vector to retrieve a bit field.

Generated on Mon Aug 15 21:43:09 2005 by Doxygen 1.2.13-20020210 written by Dimitri van Heesch © 1997-2002