Converting an Integer to a Decimal String in Under Two Nanoseconds
Ja\"el Champagne Gareau, Daniel Lemire

TL;DR
This paper presents a SIMD-based algorithm for converting integers to decimal strings that is faster than existing methods, eliminating lookup tables and adapting to input characteristics.
Contribution
A novel SIMD algorithm for integer to decimal string conversion that outperforms existing methods and adapts dynamically to input data.
Findings
Runs 1.4-2x faster than closest competitors
Outperforms std::to_chars by 2-4x across workloads
Eliminates lookup tables and uses parallel processing
Abstract
Converting binary integers to variable-length decimal strings is a fundamental operation in computing. Conventional fast approaches rely on recursive division and small lookup tables. We propose a SIMD-based algorithm that leverages integer multiply-add instructions available on recent AMD and Intel processors. Our method eliminates lookup tables entirely and computes multiple quotients and remainders in parallel. Additionally, we introduce a dual-variant design with dynamic selection that adapts to input characteristics: a branch-heavy variant optimized for homogeneous digit-length distributions and a branch-light variant for heterogeneous datasets. Our single-core algorithm consistently outperforms all competing methods across the full range of integer sizes, running 1.4-2x faster than the closest competitor and 2-4x faster than the C++ standard library function std::to_chars across…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
