Woodstock Blog

a tech blog for general algorithmic interview questions

[Fundamental] Java Bit Operation

Bit operators

operator what is means
~ invert every bit
<< shift left (same as *2)
>> signed shift right
>>> unsigned shift right
^ XOR
| OR


Note the unsigned right shift operator “>>>” shifts a zero into the leftmost position, while the leftmost position after “>>” depends on sign extension.