4 ms·
I recall needing this on a snprintf() implementation. Isn't this effectively a table-optimized logBase(x) rounded-up to the ceiling, which can be reduced to ef
by failwhaleshark 5y ago
I recall needing this on a snprintf() implementation.
Isn't this effectively a table-optimized logBase(x) rounded-up to the ceiling, which can be reduced to efficient log2(x)/log2(Base)? If you know the base, then you can combine many ops into table-lookups.
As an exercise to the reader, I suggest creating efficient code constrained to 32-bit or 16-bit unsigned.
PS: I was going to say "look at Hacker's Delight." I can definitely read. LOL.