Faster Double-to-String Conversion
3 days ago
- #performance
- #floating-point
- #optimization
- A new binary-to-decimal floating-point conversion method has been developed, outperforming existing algorithms like Dragonbox, Schubfach, and std::to_chars.
- Performance improvements include being ~68% faster than Dragonbox and ~59 times faster than sprintf on macOS.
- Key optimizations include fewer integer multiplications, faster logarithm approximations, and branchless handling of irregular rounding intervals.
- The method reduces the number of candidate numbers from 2-4 to 1-3, streamlining the conversion process.
- Improvements in significand and exponent output include using lookup tables for decimal digits and branchless removal of trailing zeros.
- The algorithm is planned for integration into {fmt} and could benefit JSON serialization in Thrift and other applications.
- Current limitations include support only for exponential format, with plans to add fixed format in the future.