Comment by IshKebab
2 days ago
> I wonder if there is a more efficient way to determine that shortest representation rather than running printf/scanf in a loop?
Yes, just `printf("%f", ...);` will get you that.
The actual algorithms to do the float->string conversion are quite complicated. Here is a recent pretty good one: https://github.com/ulfjack/ryu
I think there's been an even more recent one that is even more efficient than Ryu but I don't remember the name.
No comments yet
Contribute on Hacker News ↗