The repeated division trick has a quicker counterpart, which is to create a separate variable and repeatedly multiply that by 10, comparing to the original as it goes. Probably not as fast as anything beyond the repeated division trick, but I mention it because its rediscovery was likely missed by jumping right to
clzltricks.It also generalises a lot more readily to numbers in other bases. Kind of a “jack of all trades, master of none” solution.
Fun read, thanks for sharing ♥️
Ofc!! Thank you for reading!
So there is a faster one in Africa or Asia? Then why not use that?
We’re still searching for those…
Amazing. It’s so weird, I was just needing to do this same operation and was looking into some of the bithacks. Although I don’t have the ability in the language to fully utilize this, I am astounded by how lean you made it.
How interesting! What language are you using? I’ve ported a couple of these ilog10 methods to different languages so perhaps I could be of some help! Thank you though! It was a long process to get it this fast and lean!
Java. I could certainly use a lot of what you wrote, but I don’t know nearly enough about the JVM to take it as far as you did.
I actually have ported the pre Lemire version to Java!
This should work for you, and I can probably port my most recent version to Java as well.
Wrote my first real blog post. Let me know what you guys think!



