electroRF
Member
Hi,
I ran into the following question.
you got a 4-byte number - num.
You're given additional number - count.
you need to return the index of the count'th '1' bit in num, from the right.
Example:
num = 0x05-30-21-04
count = 2
you need to return 8, because that is the index of num where the 2nd '1' occurs.
How would you do it without having a worst case of 32 'masking' operations to find the count'th bit?
Thanks
I ran into the following question.
you got a 4-byte number - num.
You're given additional number - count.
you need to return the index of the count'th '1' bit in num, from the right.
Example:
num = 0x05-30-21-04
count = 2
you need to return 8, because that is the index of num where the 2nd '1' occurs.
How would you do it without having a worst case of 32 'masking' operations to find the count'th bit?
Thanks