bithacks Namespace Reference


Functions

unsigned int log2_32 (uint32_t v)
unsigned int log2_64 (uint64_t v)
template<class Int>
unsigned int log2 (Int v)
uint32_t ceil_pow2_32 (uint32_t v)
uint64_t ceil_pow2_64 (uint64_t v)
template<class Int>
unsigned int ceil_pow2 (Int v)
int log2_norm (float v)
int log2_norm (double v)


Detailed Description

All the code here is adapted from Sean Anderson's bit twiddling hacks page. http://graphics.stanford.edu/~seander/bithacks.html


Function Documentation

template<class Int>
unsigned int bithacks::ceil_pow2 Int  v  ) 
 

uint32_t bithacks::ceil_pow2_32 uint32_t  v  )  [inline]
 

uint64_t bithacks::ceil_pow2_64 uint64_t  v  )  [inline]
 

template<class Int>
unsigned int bithacks::log2 Int  v  ) 
 

unsigned int bithacks::log2_32 uint32_t  v  )  [inline]
 

unsigned int bithacks::log2_64 uint64_t  v  )  [inline]
 

int bithacks::log2_norm double  v  )  [inline]
 

Return the exponent of a normalized double. On a denorm, this returns the bias of -1023. Strongly assumes IEEE. Faster than frexp. Obvious extension by bhudson.

int bithacks::log2_norm float  v  )  [inline]
 

Return the exponent of a normalized float. On a denorm, this returns the bias of -127. Strongly assumes IEEE. Faster than frexpf. Proper non-punning version of what's on the bithacks page.


Generated on Thu Mar 27 19:04:16 2008 by  doxygen 1.4.6