for 16bit ..take a number n = 1000000000000000
let x be the number mentionf in a question
pos  = -1
while (1){
if(x & n){
pos++
exit}
else
n ยป=1
}

pos is the answer
if pos is greater than numbr of bits then x doesnt hv set bits

> How to find the LEFT MOST set bit in an unsigned integer.
> Example:
> "00*1*0 0001 0100 0010" is a 16-bit unsigned integer. We have to find the
> left most set bit position (Starting with 0 from right side )
> which is 13th position in our example. How to find this. Can any one pls
> give any suggestions.
> Thank You Very Much In Advance.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/algogeeks/-/HJnuFujMZ3wJ.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to