将二进制浮点数转换为最短的十进制字符串:一项实证回顾
Converting Binary Floating-Point Numbers to Shortest Decimal Strings: An Experimental Review
AI总结:
本文通过实证研究比较了多种二进制浮点数到十进制字符串转换算法的性能,发现前沿技术在速度上显著优于传统方法,但标准库实现仍有优化空间。
摘要:
在分享或记录数值数据时,我们必须将二进制浮点数转换为其十进制字符串表示。例如,数字π可能变成3.1415927。工程师已经完善了许多产生这种准确且短字符串的算法。我们对多种硬件架构和数据集进行了实证比较。前沿技术如Schubfach和Dragonbox在速度上比Steele和White的Dragon4快十倍,执行转换时的指令数少至210条,而Dragon4则为1500-5000条。根据其规范,我们调查的实现中没有一个始终能生成最短的字符串——一些生成的输出比最优解长达30%。我们发现,C++和Swift等语言的标准库实现执行的指令数显著多于最快的算法,性能差距因CPU架构和编译器而异。我们为未来研究提出了一些优化目标。
英文摘要:
When sharing or logging numerical data, we must convert binary floating-point numbers into their decimal string representations. For example, the number $π$ 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.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。