- drop the first bit
x >> 1;
- drop LSB (the least Significant bit)
x & (x - 1);
- extracts the lowest set bit of x (all other bits are cleared)
x & !(x - 1);
- extracts i-th bit
(x >>> i) & 1;
- flip bit value
x ^= 1;
- extracts part of bits from x using bit mask
// e.g : extract the 2nd 2 bytes (16 bits) from long x
x = x >> 16; // step 1. get rid of unwanted part (the first 2 bytes)
x = x & 0xFFFF; // step 2. extract only the bit mask number of bits, in this case, the bit mask is 16 bits