Blogs / Personal blogs

Vaibhav Sagar

vaibhavsagar.com

Popular posts
4
Total points
727
HN comments
483
Rank
#3,263 personal

Visit vaibhavsagar.com → RSS feedOn Hacker News May 2017 – Oct 2025

Software Engineering 4Programming Languages 2Systems & Performance 1Math & Algorithms 1

1

Popcount CPU instruction

Most CPU architectures in use today have an instruction called popcount , short for “population count”. Here’s what it does: it counts the number of set bits in a machine word. For example (assuming 8-bit words for simplicity), popcount(00100110) is 3 and popcount(01100000) is 2 .