Learn
Practice
Newsletter
Resources
F
Toggle theme
0
F
Toggle theme
0
Toggle menu
← Back to All Animations
Number of 1 Bits
Bookmark
Input
Example 1: 1011
Example 2: 10000000
Example 3: 11111111
Custom
n
=
11
bit 7
bit 6
bit 5
bit 4
bit 3
bit 2
bit 1
bit 0
0
0
0
0
1
0
1
1
Set (1)
Clearing
Just cleared
n = 11 (00001011)
count = 0
algo
master
.
io
Step:
Start: n = 11 (00001011). Count the number of 1-bits.
0 / 11
Input
Example 1: 1011
Example 2: 10000000
Example 3: 11111111
Custom
n
=
11
0 / 11
bit 7
bit 6
bit 5
bit 4
bit 3
bit 2
bit 1
bit 0
0
0
0
0
1
0
1
1
Set (1)
Clearing
Just cleared
n = 11 (00001011)
count = 0
algo
master
.
io
Step:
Start: n = 11 (00001011). Count the number of 1-bits.