Saved in:
Bibliographic Details
Main Authors: Gareau, Jaël Champagne, Lemire, Daniel
Format: Preprint
Published: 2026
Subjects:
Online Access:https://arxiv.org/abs/2604.26019
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866915984254697472
author Gareau, Jaël Champagne
Lemire, Daniel
author_facet Gareau, Jaël Champagne
Lemire, Daniel
contents 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 tested workloads.
format Preprint
id arxiv_https___arxiv_org_abs_2604_26019
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle Converting an Integer to a Decimal String in Under Two Nanoseconds
Gareau, Jaël Champagne
Lemire, Daniel
Data Structures and Algorithms
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 tested workloads.
title Converting an Integer to a Decimal String in Under Two Nanoseconds
topic Data Structures and Algorithms
url https://arxiv.org/abs/2604.26019