4 ms·
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
by adgjlsfhk1 10mo ago
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).
- nhatcher 10mo agoOh wow, I would love to see that if you can share it :)
- adgjlsfhk1 10mo agoOnce I finish it, I'll be PRing to the Julia repo (to replace the current Ryu version), and I'll drop a link here.
- vitaut 10mo agoI started a section to list implementations in other languages: https://github.com/vitaut/zmij?tab=readme-ov-file#other-languages https://github.com/vitaut/zmij?tab=readme-ov-file#other-lang.... Once yours is complete feel free to submit a PR to add it there.
- adgjlsfhk1 10mo agoNot adding it until complete, but https://github.com/JuliaLang/julia/pull/60439 https://github.com/JuliaLang/julia/pull/60439 is the draft.
- vitaut 10mo agoCool, please share once it is complete. C++ also provides countl_zero: https://en.cppreference.com/w/cpp/numeric/countl_zero.html 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.