bit twiddling in java - decomposing long into long[] of bitmasks
问题 I am decomposing a single long into a long[] of single bit longs by public static int decompose(long[] buffer, long base) { int count = Long.bitCount(base); for (int i=0; i<count; i++) { base ^= (buffer[i] = Long.lowestOneBit(base)); } return count; } but I feel like there might be a faster way to do this, since it seems like there are some repeated steps. For example, counting the bits should already come pretty close to getting all the info needed to populate the result. Any suggestions? I