AlgoScope

Lowest Set Bit

AlgorithmintermediateBit Manipulation

n and -n keeps only the lowest 1. It is the step a Fenwick tree takes.

Result · step 2 of 2Bit Manipulation: Isolate the lowest 1
0001021✓314051607bit

88 and -88 = 8, which is bit 3 alone. This is the step a Fenwick tree takes to find its parent.

Open in the player →or start at step 2

What you will see

Two's complement of n lines up under n; AND leaves a single bit.

How bit manipulation works →

Cost

BestO(1)
AverageO(1)
WorstO(1)
SpaceO(1)

How you work with it here

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

Screen readers: Each bit announces its position and value; each step announces the operation and the resulting number in binary and decimal.

Reduced motion: Bits flip with a crossfade; masks appear in place.

Before this

Leads to

Topics that need this one first.

Taught by the same lesson

Bit Manipulation covers these too, in the same run.