xjb: Fast Float to String Algorithm
Benchmark results for random and fixed-length double-precision numbers (excluding NaN and Inf)摘要
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.
类型
出版物
Computers

Authors
王铁军
(he/him)
团队负责人
2010年12月毕业于电子科技大学,获计算机应用技术工学博士学位,先后承担和参与包括国家科技支撑计划、四川省科技计划、四川省软科学研究计划、中国电力科学研究院、四川大学在内的科研项目10余项,获省科技进步二等奖2项,发表学术论文20余篇,其中SCI/EI检索10余篇,授权国家发明专利5项,获得软件著作权14项,出版教材4本。