How to do “indexOf” and “lastIndexOf” on an integer with bit flags? (Get the *power* of the found index)
问题 This is a follow up on my previous question on bit flags, where I cleared up some big misconceptions. I need to create these functions to find a single bit-flag in an int containing zero or more flags: BitBinaryUtil int twoExponentOfHighestOneBit(int all_flags) int twoExponentOfHighestOneBitAtMost(int all_flags, int twoExponentOfTwo_max0Thr30Incl) int twoExponentOfLowestOneBit(int all_flags) int twoExponentOfLowestOneBitAtLeast(int all_flags, int twoExponentOfTwo_min0Thr30Incl) Which are