01 VISUAL CSCOMPUTER SCIENCE / 01

THE BINARY PLAYGROUND

Small shift.
Big difference.

What does << actually do? Change a number, move its bits, and watch the math happen.

Bit shift lab

UNSIGNED · 8 BITS
Try it:
STARTING REGISTERClick any bit to flip it
Ready to explore

CURRENT VALUE

45

Every position has a value.

Add the highlighted place values to turn binary into decimal. A left shift moves each bit to a position worth twice as much.

45 = 00101101₂
01 / POSITION

Same bits. New value.

Move left and each position is worth twice as much. Move right and it is worth half as much; the lowest bit is discarded.

02 / THE EDGE

Eight slots. That’s it.

An unsigned 8-bit register holds 0–255. Bits that leave the edge are lost, and empty positions fill with zeros.

03 / YOUR TURN

Predict the result.

Hint: there is no slot for 256.