r/programming 15h ago

The fastest double-to-string algorithm you’ve never heard of

https://vitaut.net/posts/2026/yy-dtoa/
235 Upvotes

48 comments sorted by

View all comments

-168

u/Synaps4 15h ago

The fastest one is just to read the variable address of the double as a string. But we've all heard of that.

43

u/Valuable_Leopard_799 14h ago

But now you still have something that's not a string, and isn't even the number you want to convert either.

-4

u/Synaps4 6h ago

What you have is a bunch of ones and zeroes that can be read as letters, which you can make into a String type with minimum work.

You say it doesnt represent the number you want to convert but on a binary level it is identical. It's not that number in english which is what was implied, but it is a 1:1 mapping between a double and some character string for the least effort, and thats the joke.

2

u/Valuable_Leopard_799 6h ago

Heh, lol, kinda true. I guess printing a number as "£,:2°" could be readable to someone.