Java – Removing lowest order bit


Given a binary number, what is the fastest way of removing the lowest order bit?

01001001010 -> 01001001000

It would be used in code to iterate over the bits of a variable. Pseudo-code follows.

while(bits != 0){
  index = getIndexOfLowestOrderBit(bits);

The possible languages I'm considering using are C and Java.

Best Solution

This is what I've got so far, I'm wondering if anyone can beat this.

bits &= bits-1