If you are going to make a beeborn game, you will not need bit positions, but values.
I have never seen your while loop, good. Personally, I like this one:
int tst = 255; for(int looper = tst, i = Integer.highestOneBit(looper); looper != 0; looper &= ~i, i = Integer.highestOneBit(looper)) { System.out.println(i); }
Jacco source share