Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22157

GCC Bit-scan-forward to find next set bit?

$
0
0

I have a uint64_t and I would like to find the index of the first set bit, reset it to zero and find the next set bit.

How do I know when to terminate? BSF on all zeros is undefined...

const uint64_t input = source;if(0 != input){    int32_t setIndex = GCC_BSF_INTRINSIC(input);    while(setIndex != UNDEFINED???){        //Do my logic        //Reset        input[setIndex] = 0;        setIndex = BSF_Variant(input);    }}

Could somebody please help?


Viewing all articles
Browse latest Browse all 22157

Trending Articles