Converting an Integer to a Decimal String in Under Two Nanoseconds
Software: Practice and Experience · 2026-08 · 56 (8) · 963-977
DOI: 10.1002/spe.70079 ↗At a glance
Journal article in Software: Practice and Experience, published online on 2026-05-06. Written by Jaël Champagne Gareau and 1 co-authors. 26 references. The full text is freely available (open access, CC BY 4.0). Funded by: Natural Sciences and Engineering Research Council of Canada, Fonds de recherche du Québec.
Abstract (original language)
Objective
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. The goal of this work is to develop a significantly faster method for this task.
Methods
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.
Results
Our single‐core algorithm consistently outperforms all competing methods across the full range of integer sizes. It runs 1.4–2× faster than the closest competitor and 2–4× faster than the C++ standard library function ‘ std::to_chars ’ across tested workloads.
Conclusion
The proposed SIMD‐based approach with dual‐variant dynamic selection provides a substantial performance improvement for integer‐to‐decimal conversion, delivering superior speed without relying on traditional lookup tables.
Funding
- Natural Sciences and Engineering Research Council of Canada
- Fonds de recherche du Québec
Cite
APA
Gareau, J. C., & Lemire, D. (2026). Converting an Integer to a Decimal String in Under Two Nanoseconds. Software: Practice and Experience, 56(8), 963-977. https://doi.org/10.1002/spe.70079
Vancouver
Gareau JC, Lemire D. Converting an Integer to a Decimal String in Under Two Nanoseconds. Software: Practice and Experience. 2026;56(8):963-977. doi:10.1002/spe.70079
BibTeX
@article{Gareau2026,
author = {Gareau, Jaël Champagne and Lemire, Daniel},
title = {Converting an Integer to a Decimal String in Under Two Nanoseconds},
journal = {Software: Practice and Experience},
year = {2026},
volume = {56},
number = {8},
pages = {963--977},
doi = {10.1002/spe.70079}
}
EUVIMED