xjb: Fast Float to String Algorithm
Apr 27, 2026·
·
0 min read
Junbo Xiang
Tiejun Wang
Benchmark results for random and fixed-length double-precision numbers (excluding NaN and Inf)Abstract
Efficiently and accurately converting floating-point numbers to decimal strings remains a fundamental challenge in numerical computation, data serialization, and human–computer interaction. While modern algorithms such as Ryū, Dragonbox, and Schubfach rigorously satisfy the Steele–White criteria for correctness and minimal output length, their performance is frequently constrained by branch mispredictions, high-precision multiplication overhead, and suboptimal utilization of instruction-level parallelism. This paper introduces xjb, a novel floating-point–string conversion algorithm derived from Schubfach that systematically overcomes these bottlenecks. By restructuring the core computation to reduce instruction dependencies, adopting branchless decision logic, and exploiting SIMD instruction sets for decimal-to-ASCII formatting, xjb delivers state-of-the-art throughput across diverse hardware platforms. The algorithm requires only a single 64-by-128-bit multiplication for IEEE 754 binary64 conversions and a single 64-by-64-bit multiplication for binary32, drastically decreasing arithmetic complexity. Extensive benchmarking on AMD R7-7840H and Apple M1/M5 processors demonstrates that xjb consistently outperforms leading contemporary implementations. Notably, on the Apple M5, xjb achieves speedups of approximately 20% and 136% for binary64 and binary32 conversions, respectively, when compared to the highly optimized zmij library. The algorithm is fully compliant with the Steele–White principle; exhaustive validation over the entire binary32 space and extensive random testing across the binary64 range confirm both its theoretical soundness and practical robustness.
Type
Publication
Computers

Authors
Tiejun Wang
(he/him)
Team Leader
Received Ph.D. in Computer Application Technology from University of Electronic Science and Technology of China (UESTC) in December 2010. Has undertaken more than 10 research projects including the National Science and Technology Support Program, Sichuan Provincial Science and Technology Program, and projects from State Grid Corporation of China. Awarded two Second-Class Provincial Science and Technology Progress Awards. Published over 20 academic papers (10+ indexed by SCI/EI), authorized 5 national invention patents, obtained 14 software copyrights, and published 4 textbooks.