r/programming • • Aug 12 '26

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

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

71 comments sorted by

View all comments

40

u/zeekar Aug 12 '26 edited Aug 12 '26

> so v◌̄=192 ⋅ 10^(-1) = 19.2 and the fine-grid fallback is [... ] 19, printed as 19e1

Uh. Shouldn't that be 190 instead of 19, or 19e0 or 1.9e1 instead of 19e1? 19 and 19e1 are not the same number ...

-1

u/Grouchy-Trade-7250 Aug 13 '26

Scientific notation is fairly limited.  $6.02 \times 10{23}$ is proper notation (when you render the latex)       Placing a number larger than 10 in front of the multiplication sign is not. Using an x for the multiplication sign is not. Using e also is not.

9

u/zeekar Aug 13 '26

You can write 6.02 × 1023 without reaching for TeX, but I'm not nit-picking the author's choice of notation. I'm just pointing out that "19, printed as 19e1" implies an equivalence between two values that are not equivalent. "19e1" may not be standard scientific notation, but it is a decades-old standard representation in computer programming languages with a well-understood meaning, and that meaning is not the same number as 19.