AlgoScope

Get Bit

Shift right by i and keep the last bit.

Bit manipulation, algorithm, beginner
Bit 4 is 1. The mask is 16.0011020314150617bit
Bit 4 is 1. The mask is 16.0011020314150617bit

Bit Manipulation: Read one bit

Decision, step 2 of 3

The mask 1 shl 4 is 16, a single 1 at bit 4. Bit 4 of 178 is currently 1. Shift 178 right by 4 and keep the last bit.

Cost

Best
O(1)
Average
O(1)
Worst
O(1)
Space
O(1)

Leads to

Topics that need this one first.

Taught by the same lesson

Bit Manipulation covers these too, in the same run.