Submitted:
21 November 2025
Posted:
24 November 2025
You are already at the latest version
Abstract
Keywords:
1. Introduction
- Information preservation: The print result can be parsed back to the original floating-point number.
- Minimum length: The print result should be as short as possible.
- Correct rounding: On the basis of satisfying 1 and 2, if there are two candidate values, they should be correctly rounded (i.e., the even value should be selected).
- Generate from left to right: The print result is generated from the left.
2. IEEE754 Floating Point Number Representation
3. Principle of Algorithm
3.1. Review the Schubfach algorithm and the derivation of the algorithm in this paper
-
When the following conditions are met, the result is (or equivalent to ). That is, the floating-point number v minus the minimum possible value of is less than the rounded radius .Or when , must also be satisfied. Therefore, the following conditions are valid:
-
When the following conditions are met, the result is (or equivalent to ). The maximum possible value of minus the floating-point number v is less than the rounded radius .Or when , must also be satisfied. Therefore, the following conditions are valid:
-
orWhen none of the conditions are met as or , d is either or . The final value is determined based on the decimal part of . If the decimal part is 0.5, it is rounded to the nearest even value; if it is not 0.5, it is rounded to the nearest value. For irregular floating-point numbers, it is also necessary to determine whether is within the rounding interval . If it is not, then .
- Introduce the pre-computation process of the algorithm’s lookup table.
- Quickly calculate m.
- Quickly determine whether or .
- Quickly calculate and determine whether or based on the decimal part of .
- Processing of irregular floating-point numbers.
3.2. Pre-computation of Lookup Table
-
FloatThe range of is calculated to be [-32, 44] through the q value range in equation (5), so the lookup table contains representation values from 10 to the power of -32 to 10 to the power of 44. The calculation process is as follows:When , the lookup table variable indicates that the values and are equal. In other cases, the relative error is less than . Expressed as:
-
DoubleThe range of is calculated to be [-293, 323] through the q value range in equation (5), so the lookup table contains representation values from 10 to the power of -293 to 10 to the power of 323. The calculation process is as follows:When , the lookup table variable indicates that the values and are equal. In other cases, the relative error is less than . Expressed as:
3.3. Quickly Calculate m
3.4. Quickly Determine Whether or
-
From , we get .When , it is equivalent to discussing whether is divisible by . Since 2 and 5 are coprime, it is equivalent to discussing whether is divisible by .Suppose t is a positive integer:Since is odd, t is also odd. Because the following conditions exist:Therefore, the following satisfies:Therefore, the following conclusions are drawn:Therefore, the maximum value of k is 9 within the float range and 22 within the double range. Therefore, when k exceeds the above range, is not divisible by .
-
Because the denominator is even and the numerator is odd, the condition is not met.
-
Because the denominator is even and the numerator is odd, the condition is not met.
-
When , is the expression (85), the following holds true:Therefore, when , equation (82) does not hold true.
-
Call function (37) to calculate the approximation results and of all possible upper and lower limit rational numbers:Therefore, for , the following conclusion can be drawn from formula (36).By exhausting all possibilities, we thus have (the test code file is test3.py) :Therefore, when , equation (82) does not hold true.
-
When , is the expression (98), the following holds true:Therefore, when , equation (95) does not hold true.
-
Call function (37) to calculate the approximation results and of all possible upper and lower limit rational numbers:Therefore, for , the following conclusion can be drawn from formula (36).By exhausting all possibilities, we thus have (the test code file is test7.py) :Therefore, when , equation (95) does not hold true.
3.5. Determine whether or
3.5.1.
-
When , it can be concluded that , the numerator is even and the denominator is odd, which does not meet the condition.
-
When , it can be concluded that is even, which does not meet the condition.
-
is an odd number. c is an odd multiple of . So:Therefore, when q meets the above conditions, c must be an odd multiple of to meet the condition. Therefore, when the following conditions are met, expression (147) is an odd number:The following equation holds:Since , is multiple of 5 and is an odd number. Since and are both odd numbers, is an even number, is multiple of 5 and is an odd number. Therefore, there is:The result of is an even number between and . Therefore, when the following conditions are met:
3.5.2.
3.6. Irregular Number
4. Benchmark Result
5. Conclusions and Future Work
Acknowledgments
References
- G. L. Steel Jr. and J. L. White. How to Print Floating-Point Numbers Accurately. In Proceedings of the ACM SIGPLAN 1990 Conference on Programming Language Design and Implementation, PLDI 1990. ACM, New York, NY, USA, 112-126. [CrossRef]
- F. Loitsch. Printing Floating-Point Numbers Quickly and Accurately with Integers. In Proceedings of the ACM SIGPLAN 2010 Conference on Programming Language Design and Implementation, PLDI 2010. ACM, New York, NY, USA, 233-243. [CrossRef]
- M. Andrysco, R. M. Andrysco, R. Jhala, and S. Lerner. Printing Floating-Point Numbers: a Faster, Always Correct Method. In Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2016. ACM, New York, NY, USA, 555-567. [CrossRef]
- Ulf Adams. 2018. Ryu¯: Fast Float-to-String Conversion. In Proceed- ings of 39th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI’18). ACM, New York, NY, USA, 13 pages. [CrossRef]
- Ulf Adams. 2019. Ryu¯ Revisited: Printf Floating Point Conversion. Proc. ACM Program. Lang. 3, OOPSLA, Article 169 (October 2019), 23 pages. [CrossRef]
- R. Giulietti. The Schubfach Way to Render Doubles. 2020. https://drive.google.com/file/d/1KLtG_LaIbK9ETXI290zqCxvBW94dj058/view (Sep. 2020.
- J. Jeon. Grisu-Exact: A Fast and Exact Floating-Point Printing Algorithm. 2020. https://github.com/jk-jeon/Grisu-Exact/blob/master/other_files/Grisu-Exact.pdf. (Sep. 2020.
- Junekey Jeon. 2024. Dragonbox: A New Floating-Point Binary-to-Decimal Conversion Algorithm. https://github.com/jk-jeon/Dragonbox.
- Guo YaoYuan. https://github.com/ibireme/c_numconv_benchmark/blob/master/vendor/yy_double/yy_double.c (Nov. 2024.
- Victor Zverovich. https://github.com/fmtlib/fmt (Oct. 2025.
- Guo YaoYuan. https://github.com/ibireme/yyjson (Aug. 2025.
- Cassio Neri. https://github.com/cassioneri/teju_jagua (Nov. 2025.
| algorithm | float | double | description |
|---|---|---|---|
| ]1*Schubfach | Schubfach32 | Schubfach64 | author:Raffaello Giulietti,https://github.com/c4f7fcce9cb06515/Schubfach. |
| ]1*Schubfach_xjb | Schubfach32_xjb | Schubfach64_xjb | It is improved by Schubfach and has the same output result. |
| ]1*Ryu | Ryu32 | Ryu64 | author:Ulf Adams,https://github.com/ulfjack/ryu. |
| ]1*Dragonbox | Dragonbox32 | Dragonbox64 | author:Junekey Jeon,https://github.com/jk-jeon/Dragonbox. |
| ]1*fmt[10] | fmt32 | fmt64 | author:Victor Zverovich,https://github.com/fmtlib/fmt version:12.1.0 |
| ]1*yy_double | - | yy_double | author:Guo YaoYuan,https://github.com/ibireme/c_numconv_benchmark/blob/master/vendor/yy_double/yy_double.c. |
| ]1*yy_json[11] | yy_json32 | yy_json64 | author:Guo YaoYuan,https://github.com/ibireme/yyjson version:0.12.0 |
| ]1*teju_jagua[12] | teju32 | teju64 | author:Cassio Neri,https://github.com/cassioneri/teju_jagua. |
| ]1*xjb | xjb32 | xjb64 | this paper,https://github.com/xjb714/xjb. |
| algorithm | float | double | |||||
|---|---|---|---|---|---|---|---|
| gcc 13.3 | icpx 2025.0.4 | clang 18.1.3 | gcc 13.3 | icpx 2025.0.4 | clang 18.1.3 | ||
| Schubfach | 11.72 | 11.26 | 11.26 | 11.96 | 12.07 | 11.97 | |
| Schubfach_xjb | 7.50 | 5.38 | 5.45 | 8.70 | 6.43 | 7.48 | |
| Ryu | 14.23 | 14.21 | 14.48 | 13.73 | 13.53 | 13.59 | |
| Dragonbox | 10.47 | 9.96 | 9.52 | 10.44 | 10.15 | 10.00 | |
| yy_json | 6.31 | 4.84 | 4.69 | 7.20 | 6.10 | 6.25 | |
| yy_double | - | - | - | 6.32 | 5.75 | 5.22 | |
| teju_jagua | 13.73 | 14.90 | 14.39 | 13.38 | 15.23 | 13.59 | |
| xjb | 3.38 | 2.88 | 4.19 | 7.15 | 3.90 | 3.60 | |
| 1.88(AVX2) | 3.13(AVX2) | ||||||
| 1.68(AVX512) | 3.47(AVX512) | ||||||
| algorithm | float | double | |||||
|---|---|---|---|---|---|---|---|
| gcc 13.3 | icpx 2025.0.4 | clang 18.1.3 | gcc 13.3 | icpx 2025.0.4 | clang 18.1.3 | ||
| Schubfach | 20.71 | 19.67 | 20.32 | 25.78 | 24.55 | 24.76 | |
| Schubfach_xjb | 21.04 | 19.99 | 20.49 | 20.14 | 20.23 | 20.37 | |
| Ryu | 22.57 | 20.58 | 20.62 | 26.36 | 24.71 | 24.95 | |
| Dragonbox_comp | 21.73 | 20.65 | 22.84 | 21.69 | 21.37 | 22.72 | |
| Dragonbox_full | 16.93 | 15.49 | 17.28 | 18.88 | 17.78 | 18.80 | |
| fmt_comp | 22.45 | 22.81 | 21.76 | 26.35 | 27.14 | 26.78 | |
| fmt_full | 23.05 | 23.31 | 22.21 | 25.67 | 27.28 | 26.13 | |
| yy_json | 21.71 | 21.09 | 21.08 | 18.13 | 18.03 | 19.16 | |
| yy_double | - | - | - | 17.54 | 17.52 | 17.85 | |
| xjb | 9.04 | 9.02 | 8.78 | 12.15 | 9.12 | 15.78 | |
| algorithm | float | double | |
|---|---|---|---|
| apple clang 17.0.0 | apple clang 17.0.0 | ||
| Schubfach | 10.94 | 12.62 | |
| Schubfach_xjb | 5.92 | 6.58 | |
| Ryu | 15.40 | 14.16 | |
| Dragonbox | 11.94 | 12.03 | |
| yy_json | 4.18 | 4.72 | |
| yy_double | - | 4.74 | |
| teju_jagua | 19.27 | 18.66 | |
| xjb | 3.24 | 3.53 | |
| algorithm | float | double | |
|---|---|---|---|
| apple clang 17.0.0 | apple clang 17.0.0 | ||
| Schubfach | 23.26 | 27.51 | |
| Schubfach_xjb | 23.30 | 22.44 | |
| Ryu | 25.27 | 29.15 | |
| Dragonbox_comp | 28.55 | 27.28 | |
| Dragonbox_full | 21.03 | 22.12 | |
| fmt_comp | 37.19 | 41.73 | |
| fmt_full | 36.36 | 41.77 | |
| yy_json | 15.50 | 15.58 | |
| yy_double | - | 15.13 | |
| xjb | 8.91 | 10.32 | |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).