Converting Binary Floating-Point Numbers to Shortest Decimal Strings: An Experimental Review

Jaël Champagne Gareau, Daniel Lemire · 2026

Read Converting Binary Floating-Point Numbers to Shortest Decimal Strings: An Experimental Review by Jaël Champagne Gareau, Daniel Lemire (2026) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2603-06581.txt.

Introduction

Gareau and Lemire present an empirical comparison of algorithms converting binary floating-point numbers into decimal string representations, across diverse hardware architectures and datasets. Techniques such as Schubfach and Dragonbox achieve a tenfold speedup against Steele and White's Dragon4, executing only 210 instructions per conversion at fewest, against Dragon4's thousands. None of the surveyed implementations produced the shortest strings, with some outputs up to 30 percent longer than optimal, and library implementations execute more instructions than the fastest methods. The authors suggest optimization targets for future research.

Catalog record

CREATORJaël Champagne Gareau, Daniel Lemire
YEAR2026
COLLECTIONPAPERS
FORMATTXT
FILE SIZE73503
LICENSEhttp://creativecommons.org/publicdomain/zero/1.0/
RIGHTSCC0
SOURCEarXiv

Source: https://arxiv.org/abs/2603.06581

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

Converting Binary Floating-Point Numbers to Shortest Decimal Strings: An Experimental Review Jaël Champagne Gareau, Daniel Lemire Abstract When sharing or logging numerical data, we must convert binary floating-point numbers into their decimal string representations. For example, the number π \pi might become 3.1415927 . Engineers have perfected many algorithms for producing such accurate, short strings. We present an empirical comparison across diverse hardware architectures and datasets. Cutting-edge techniques like Schubfach and Dragonbox achieve up to a tenfold speedup over Steele and White’s Dragon4, executing as few as 210 instructions per conversion compared to Dragon4’s 1500–5000 instructions. Often per their specification, none of the implementations we surveyed consistently produced the shortest possible strings—some generate outputs up to 30% longer than optimal. We find that standard library implementations in languages such as C++ and Swift execute significantly more instructions than the fastest methods, with performance gaps varying across CPU architectures and compilers. We suggest some optimization targets for future research. \corraddress Daniel Lemire, Université du Québec (TELUQ), Montreal, Quebec, H2S 3L5, Canada \corremail [email protected] \fundinginfo Natural Sciences and Engineering Research Council of Canada, Grant Number: RGPIN-2024-03787 Fonds de recherche du Québec, https://doi.org/10.69777/361128 keywords Floating-point numbers, Shortest-string algorithms, Performance benchmarking 1 Introduction Processor vendors have adopted 32-bit and 64-bit IEEE 754 floating-point numbers. Consequently, we typically represent numbers as IEEE 754 floating-point numbers in software. The corresponding types in Java, C, C# and C++ are float and double . JavaScript uses the 64-bit IEEE 754 floating-point format as its default number data type. These numbers take the form of a fixed-precision integer (the significand 1 1 1 The term mantissa is sometimes used as a synonym for significand , but this usage is discouraged by the IEEE 754 standard, which reserves the term significand to denote the fractional component of a floating-point number. In contrast, mantissa historically referred to the fractional part of a logarithm. ) multiplied by a power of two ( m\times 2^{p} ). For example, a 32-bit floating-point value approximating the constant \pi is 13176795\times 2^{-22} . We often convert these binary values into decimal strings: • when we serialize data to text formats like CSV, JSON or YAML; • when we produce human-readable logs and telemetry; • when we print numbers in graphical interfaces, spreadsheets and dashboards. Producing the shortest possible string that exactly reproduces the original value can require hundreds or even thousands of CPU instructions. Since many applications convert millions or even billions of values in bulk, that per-value overhead may quickly add up to a substantial performance bottleneck. Converting binary floating-point values into decimal strings is largely a matter of established software practices, yet it remains under-explored in the research literature. In Section 2 , we formally define the shortest-string conversion problem. In Section 3 , we survey the principal algorithmic families. Finally, we present an experimental comparison of key implementations in Section 4 —ranging from Steele and White’s 1990 Dragon4 to modern methods like Schubfach and Dragonbox—and present some directions for future work in Section 5 . Taken together, our study offers both a broad empirical perspective and new methodological insights. Our main contributions are the following: • A systematic empirical evaluation of major conversion algorithms , spanning both dominant CPU families (x86-64 and ARM/AArch64) and an expanded, openly available benchmark suite including mostly real-world datasets. • New measurements of output behavior , including the first detailed characterization of end-to-end string lengths—which often differ from minimal significand lengths—and instruction-level metrics that isolate algorithmic cost from microarchitectural throughput. • A reassessment of existing benchmarking practices , identifying methodological limitations in prior evaluations. 2 Problem Definition Although IEEE 754 floating-point types are the default choice for representing real numbers in software—and are widely supported by commodity processors and programming languages—their use can lead to non-obvious difficulties. In this section, we formalize the problem and outline its practical implications. Table 1 describes the bit layouts of 32- and 64-bit floating-point numbers. The IEEE 754 formats dedicate a bit for the sign: accordingly, we can distinguish between -0 and 0 . A positive normal double-precision floating-point number is a binary floating-point value whose significand is represented with 53 bits of precision: 52 bits are explicitly stored, while the leading 1 bit is implicit (not physically stored in memory). For example, the value with a significand of 1.011_{2} would be stored as an implicit leading 1 and explicit bits 011 . As such, the significand can be seen as a 53-bit integer m in the interval [2^{52},2^{53}) but interpreted as a number in [1,2) by dividing it by 2^{52} . The 11-bit exponent p ranges from -1022 to 1023 [ 12 ] . Values smaller than 2^{-1022} are called subnormal values: their special exponent code has the value 2^{-1022} and the significand is then interpreted as a value in [0,1) . We can uniquely identify a 64-bit number using a 17-decimal-digit representation, although fewer digits are often needed. The 32-bit numbers are similarly defined, with a 24-bit significand m and an 8-bit exponent p ranging from -126 to 127 . Numbers smaller than 2^{-126} are represented using a subnormal format. We have that 9 digits are sufficient to uniquely identify a 32-bit number. Table 1 : Common IEEE 754 binary floating-point numbers name exponent bits significand (stored) decimal digits (exact) binary64 11 bits 53 bits (52 bits) 17 binary32 8 bits 24 bits (23 bits) 9 String representations are typically in decimal format. Converting a binary floating-point number to a decimal string is usually done in three steps: 1. Extracting the sign bit, exponent, and significand; 2. Converting the binary significand and exponent to their decimal counterparts; 3. Generating the string representation of the resulting decimal number. See Fig. 1 . The first step—extracting the three fields from the bit pattern—is straightforward and leaves little room for algorithmic innovation. Consequently, most research has focused on the second step: the conversion of a value from a base-2 representation ( m\times 2^{p} ) to a base-10 representation ( w\times 10^{q} ). This conversion involves determining the decimal significand w and exponent q from the binary significand m and exponent p by solving the equation m\times 2^{p}=w\times 10^{q} [ 22 ] . Sign bit 1 bit 0 or 1 (-0 or +0) Exponent 11 bits p\in[-1022,+1023] Significand 53 bits (1 implicit + 52 explicit) m\in[2^{52},2^{53}) , interpreted in [1,2) Ex: 1.011_{2} stored as 011 +/- Convert to decimal Decimal string representation Figure 1 : Conversion of a 64-bit number to a string An exact solution is always possible in this direction (from binary floating-point to decimal string). For p\geq 0 , setting q=0 and w=m\times 2^{p} suffices, since any positive power of two is exactly representable in base ten. For p<0 , we can set q=p and w=m\times 5^{-q} , making use of the identity 2^{p}=10^{p}/5^{p} . However, the converse is not generally true: most decimal fractions cannot be represented exactly as binary floating-point numbers. For example, 0.1 cannot be expressed as m\times 2^{p} with integer m , since m=2^{-p-1}/5 would require a power of two to be divisible by 5 , which is impossible. After accounting for special cases ( \pm 0 , \pm\infty , NaN, and subnormals) and ignoring the sign

Read the complete text