logoalt Hacker News

adgjlsfhk1last Thursday at 3:12 PM2 repliesview on HN

I've just started a Julia port and I think it will be even cleaner than the C version (mostly because Julia gives you a first class (U)Int128 and count leading zeros (and also better compile time programming that lets you skip on writing the first table out explicitly).


Replies

vitautlast Thursday at 4:40 PM

Cool, please share once it is complete.

C++ also provides countl_zero: https://en.cppreference.com/w/cpp/numeric/countl_zero.html. We currently use our own for maximum portability.

I considered computing the table at compile time (you can do it in C++ using constexpr) but decided against it not to add compile-time overhead, however small. The table never changes so I'd rather not make users pay for recomputing it every time.

nhatcherlast Thursday at 3:37 PM

Oh wow, I would love to see that if you can share it :)

show 1 reply