xjb: Fast Float to String Algorithm

Read the full article See related articles

Discuss this preprint

Start a discussion What are Sciety discussions?

Listed in

This article is not in any list yet, why not save it to one of your lists.
Log in to save this article

Abstract

With the wide application of numerical computation and data exchange, efficiently and accurately converting floating-point numbers to decimal strings has become an important computer science issue. Existing floating-point printing algorithms, such as Ryu¯, Dragonbox, and Schubfach, although they meet the Steele-White (SW) principle in terms of accuracy, still have room for optimization in performance, especially in terms of branch prediction failure and high-precision multiplication overhead. This paper proposes a novel floating-point to string conversion algorithm named "xjb", which is an improvement based on the Schubfach algorithm, aiming to further enhance the conversion efficiency. The algorithm in this paper is designed for IEEE754 single-precision (binary32) and double-precision (binary64) floating-point numbers. By reducing instruction dependencies, decreasing the number of multiplication operations, and minimizing branch prediction failures, it significantly improves performance. In addition, the algorithm supports parallel computing, and the core implementation code is concise, with good portability and scalability. We conducted extensive benchmark tests on multiple platforms, including AMD-R7 7840H and Apple M1, using different compilers (gcc, clang, icpx). The results show that the xjb algorithm outperforms the existing mainstream algorithms in most cases.

Article activity feed