I was curious how much better the Algorithms, pointed out by BitTwiddling Hacks, perform than a simple Lookup Table approach...
Now I think, perhaps my little investigation is interesting for others too...

PS: the parallel counting Algo is about 35% faster on average on my computers than a simple LUT based solution. Also this shows nicely how different a human brain compatible solution is to a binary machine optimal solution :-)

In the meantime I added other Algorithms beside countbisset (hamming weight): ceil(log2()) + floor(log2()), bitreverse, ...

I also recommand to try the code with different compilers and / or plattforms.

PS: see result.txt in Code, to see various runs with different compilers and compiler switches

Features

  • C++
  • CountBitsSet, PopulationCount.Integer Hamming weight
  • simple Benchmark

Project Samples

Project Activity

See All Activity >

Categories

Algorithms

License

Public Domain

Follow CountBitsSet

CountBitsSet Web Site

Other Useful Business Software
Our Free Plans just got better! | Auth0 Icon
Our Free Plans just got better! | Auth0

With up to 25k MAUs and unlimited Okta connections, our Free Plan lets you focus on what you do best—building great apps.

You asked, we delivered! Auth0 is excited to expand our Free and Paid plans to include more options so you can focus on building, deploying, and scaling applications without having to worry about your security. Auth0 now, thank yourself later.
Try free now
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of CountBitsSet!

Additional Project Details

Operating Systems

Linux, Windows

Intended Audience

Education, Developers

User Interface

Console/Terminal, Command-line

Programming Language

C++

Related Categories

C++ Algorithms

Registered

2012-09-01