0
votes

Copied directly from MSDN...

unsigned char _BitScanReverse(  
   unsigned long * Index,  
   unsigned long Mask  
);  

Description

Search the mask data from most significant bit (MSB) to least significant bit (LSB) for a set bit (1).

Return Value

Nonzero if Index was set, or 0 if no set bits were found.

According to the return value description if no set bit were found then Index=0. But what happens in the case where the mask = 1? Running the sample code that comes with the instruction inside the MSDN documentation, it returns also 0 which confuse the programmer since he does not know if "no set bit were found" or "index equals to 1" .

Am I understanding something wrong here ?

1

1 Answers

1
votes

You're misreading the documentation. The return value is 1 or 0, depending on if there are nonzero bits in mask. The index of the set bit is returned in *Index. No confusion arises.