5 ms·
C code for Ryu is available under the Apache2 and Boost licenses: https://github.com/ulfjack/ryu/tree/master/ryu https://github.com/ulfjack/ryu/tree/master/ryu
by nwellnhof 8y ago
C code for Ryu is available under the Apache2 and Boost licenses: https://github.com/ulfjack/ryu/tree/master/ryu https://github.com/ulfjack/ryu/tree/master/ryu
Also have a look at Grisu3, Dragon4, dtoa, and the printf implementations of glibc and musl.
- stephencanon 8y agoThe two fastest options that I'm currently aware of, by a pretty wide margin, are Ryu and Swift's implementation (single C file, it's only in a C++ file to satisfy a build system quirk in Swift on linux: https://github.com/apple/swift/blob/master/stdlib/public/runtime/SwiftDtoa.cpp https://github.com/apple/swift/blob/master/stdlib/public/run..., Apache2 + run time exception). Ryu is somewhat faster for doubles, though SwiftDtoa has support for 80-bit and float out of the box, which is nice, and we have some further perf improvements planned. Both are considerably faster than any of the alternatives (some perf data in the original Swift PR: https://github.com/apple/swift/pull/15474 https://github.com/apple/swift/pull/15474), and both pass our fairly intensive test suite. musl's implementation is also interesting for reasons of simplicity.