The following functions are used to perform common bit-related operations
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 value
bit position. -1 if the input value was 0
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
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
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
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
number of set bits (0 to 32)
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
number of set bits (0 to 16)
#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