Ulf Adams claims in his paper “We present Ryu, a new routine to convert binary floating ¯
point numbers to their decimal representations using only
fixed-size integer operations, and prove its correctness. Ryu¯
is simpler and approximately three times faster than the
previously fastest implementation.” https://doi.org/10.1145/3192366.3192369
It performs better than dtoa on some inputs but the output is less human readable. For example dtoa and serde_json prefer to print 0.3 as 0.3, while Ryū currently prints it as 3E-1.
Input f64 dtoa Ryū
0.1234 47 ns 66 ns
2.718281828459045 64 ns 40 ns
1.7976931348623157e308 73 ns 42 ns
Benchmark commit: dtolnay/dtoa@655152b