Finding the first '1' of a binary number
in
Programming Questions
•
1 year ago
I have an incrementing number (frameCount) and at any given frame I want to know the position of the first '1' from the right. Something that generates this:
frameCount 1 = binary 1 = position 0
frameCount 2 = binary 10 = position 1
frameCount 3 = binary 11 = position 0
frameCount 4 = binary 100 = position 2
frameCount 5 = binary 101 = position 0
frameCount 6 = binary 110 = position 1
frameCount 7 = binary 111 = positon 0
frameCount 8 = binary 1000 = positon 3
How can I go about doing this?
1