News for hackers. Stuff that matters.
Re:Optimizing uint64_t Digit Counting: A Method that Beats L... by mabster on Tuesday January 07, 2025 @08:04PM (#42629739)
FYI, Hackers Delight uses a slight variation of Lemire's. He multiplies by 19/64 (so the divisor is a shift) and has the highest integer at the end of his table (i.e. 2^64 - 1). He also uses a shift instead of a conditional, so his code is branchless.

Generally I prefer this kind of approach. But, I suspect your digit counting is a very hot path so your tables will generally be in cache. So your approach will likely win anyway.

There are no comments on this comment yet.