Skip to main content

Left / Right Shift

Learn Left / Right Shift (Bit Manipulation, Data Structures & Algorithms) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Shifting Bits - Fast Multiplication/Division by Powers of 2 << (left shift) - shifts bits left, filling with 0s. x << n equals x &times; 2&#8319; . >> (signed right shift) - shifts bits right, preserving the SIGN bit (fills with 1s for negative numbers). x >> n equals x / 2&#8319; (rounding toward negative infinity). >>> (unsigned right shift) - shifts right, always filling with 0s, IGNORING sign - Java-specific, doesn't exist in C/C++.

More lessons in Bit Manipulation