4 ms·
Isn't this just doing the integer log to base 2 of x (or put another way, determining the highest set bit). Search for bit manipulation hacks and you'll find pe
by opk 11y ago
Isn't this just doing the integer log to base 2 of x (or put another way, determining the highest set bit). Search for bit manipulation hacks and you'll find people have already thought about how to do that as efficiently as possible. The point of the article is perhaps more to do with how gcc optimizes templates but it'd be better if the initial non-template code was less contrived.