liveBook · Manning

Bit shifting

Bit shifting is a bitwise operation that moves the positions of an integer’s binary digits left or right by a specified count.

How 2 Manning books explain it

100 Java Mistakes and How to Avoid Them

A bitwise shift operator moves the binary representation of an integer left or right by a specified number of bit positions.

How it is used
Uses shifts for packing values, masks, flags, and compact bit-vector manipulation.
How deep it goes
Explains precedence, modulo shift counts, result typing, and concrete masking corner cases.
Examples
Uses value packing, a handwritten hashCode, buffer sizing, a least-significant-bit mask, and a long field bit setter.
What you can do after
Diagnose/debug with it by checking grouping, shift-count boundaries, and left-operand types in Java expressions.

Read how 100 Java Mistakes and How to Avoid Them explains bit shifting →

Modern C

A shift operation is a C bitwise operation that moves the bits of an integer representation left or right by a specified operand.

How it is used
Uses unsigned shifts to move through bit sets, specify powers of two, and build enumeration masks.
How deep it goes
Explains bit movement, arithmetic correspondence, discarded bits, precision constraints, and signedness, without resolving negative signed shifts.
Examples
Works through A = 240, overflowed left shifts, right-shift remainders, and named enumeration masks.
What you can do after
Apply it via C shift operators to calculate powers of two, manipulate bit sets, and define flag masks.

Read how Modern C explains bit shifting →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.