One instruction to rule them all
Dear reader. In our previous section of this chapter, unfortunately, we exhausted the only pompous introduction we could borrow from various cultural sources concerning technical interviews, career and life choices, and whether should we take the red pill or the blue one, so let’s focus our attention on more technical questions that our candidates might face at a technical interview (the word technical appears four times in this short introductory paragraph).
One of these questions, served to the author of these lines a few years ago, was to write a short code snippet that will count the number of 1 bits (the on bits) in a 32-bit integer. Let’s draft up a quick application to do this:
int countOneBits(uint32_t n) { int count = 0; while (n) { count += n & 1; n >>= 1; ...