AlgoScope

Bitset

Data structureintermediateLinear Structures

An 8-bit word as an array of bits: get, set, clear and toggle are one mask operation each.

Decision · step 2 of 3Bit Manipulation: Set a bit that was 0
0011020314150617bit

The mask 1 shl 2 is 4, a single 1 at bit 2. Bit 2 of 178 is currently 0. OR with the mask forces that one bit to 1 and leaves the rest alone.

Open in the player →or start at step 2

What you will see

A row of 0/1 digits; operations flip individual digits or whole words.

How bit manipulation works →

Cost

testO(1)
setO(1)
and or xorO(n / w)
SpaceO(n / w)

w is the machine word size.

How you work with it here

play it through, step one change at a time, scrub to any step, run it on your own input, try operations in any order.

Screen readers: Each element is an accessibility element with position, value and state; structural changes are announced per step.

Reduced motion: Elements appear at their destination with a crossfade; no travel longer than the element's own size.

Before this

Leads to

Topics that need this one first.