MLib Alpha 1 API Reference

MLib Alpha 1 API Reference

Bits

The following functions are used to perform common bit-related operations


m_bits32_highest


  MLIB_API(M_Int)   m_bits32_highest( M_UInt32  val );

this function is used to return the position of the highest bit that is set to 1 in a 32-bit word


input
val

input value

return

bit position. -1 if the input value was 0


m_bits16_highest


  MLIB_API(M_Int)   m_bits16_highest( M_UInt16  val );

this function is used to return the position of the highest bit that is set to 1 in a 16-bit word


input
val

input value

return

bit position. -1 if the input value was 0


m_bits32_lowest


  MLIB_API(M_Int)   m_bits32_lowest ( M_UInt32  val );

this function is used to return the position of the lowest bit that is set to 1 in a 32-bit word


input
val

input value

return

bit position. -1 if the input value was 0


m_bits16_lowest


  MLIB_API(M_Int)   m_bits16_lowest ( M_UInt16  val );

this function is used to return the position of the lowest bit that is set to 1 in a 16-bit word


input
val

input value

return

bit position. -1 if the input value was 0


m_bits32_count


  MLIB_API(M_UInt)  m_bits32_count  ( M_UInt32  val );

this function is used to count the number of bits that are set to 1 in a 32-bit word


input
val

input value

return

number of set bits (0 to 32)


m_bits16_count


  MLIB_API(M_UInt)  m_bits16_count  ( M_UInt16  val );

this function is used to count the number of bits that are set to 1 in a 16-bit word


input
val

input value

return

number of set bits (0 to 16)


m_bits_is_power2


#define  m_bits_is_power2(x)    (((x) & ((x)-1)) == 0)

a macro that returns true iff the input value "x" is a power of 2



generated on Tue Oct 09 23:59:46 2001