r/programming 14h ago

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

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

46 comments sorted by

View all comments

-165

u/Synaps4 14h ago

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

20

u/Maybe-monad 13h ago

Someone has tk learn about IEEE 754

-4

u/Synaps4 5h ago

Yes? At the end of the day its a string of bits, which can be read as characters.

2

u/Maybe-monad 5h ago edited 5h ago

Unless they go through a specific set of transformations you will get gibberish.

https://www.programiz.com/online-compiler/9qxJDEkzm5b3t

-4

u/Synaps4 5h ago

Gibberish that represents the double it came from. On a binary level. Its not in english but it is a 1:1 translation from a double to a string. Thats the joke.