The underlying algorithm is nothing more than `grisu2` that's going to give you 
roundtrip-able values in the shortest amount of time, the tradeoff is in the 
0.05% of numbers that cannot be "encoded" in the shortest possible way.

For a stdlib implementation you may want to use something like `errol4` or 
`grisu3` plus some other fallback but, as expected, the implementation is 
slightly more complicated (see 
[Swift](https://github.com/apple/swift/blob/master/stdlib/public/runtime/SwiftDtoa.cpp)
 implementation to get a taste).

Reply via email to