TIL `std::log2p1()` calculates binary logarithm and adds 1 which is number of bit needed for storing argument
Post Naming Things: Implementer vs. User Names raises interesting question about choosing convinient name for functions.
E.g. std::log2p1()
function calculates binary logarithm and adds 1, but for 0 returns zero. Is it useful? It is. It calculates number of bit needed for storing argument, but just looking at the name doesn’t really make it apparent.
Didn’t know there’s CPU instruction popcount
doing exact that:
The population count (or popcount) of a specific value is the number of set bits in that value. For example, the population count of 0F0F₁₆, 111116₁₆, and 00₁₆ are 8₁₀, 4₁₀, and 0₁₀ respectively.
It’s interesting popcount is actually a Hamming weight of a word.
Learned that stride parameter in some vDSP functions might be strange, like in vDSP_polarD(_:_:_:_:_:)
when stride parameneter must be even.