How to use
_BitScanReverse64(unsigne开发者_如何学Pythond long * Index, unsigned __int64 Mask)
in order to find a first position set to 1 in integer?
Try this:
unsigned __int64 mask = some_value;
unsigned long index;
unsigned char isNonzero = _BitScanReverse64(&index, mask);
if (!isNonzero) {
// index variable contains index of the first bit set to 1
}
精彩评论