Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
research-article
Open access

Ryū revisited: printf floating point conversion

Published: 10 October 2019 Publication History
  • Get Citation Alerts
  • Abstract

    Ryū Printf is a new algorithm to convert floating-point numbers to decimal strings according to the printf %f, %e, and %g formats: %f generates ‘full’ output (integer part of the input, dot, configurable number of digits), %e generates scientific output (one leading digit, dot, configurable number of digits, exponent), and %g generates the shorter of the two. Ryū Printf is based on the Ryū algorithm, which converts binary floating-point numbers to the shortest equivalent decimal floating-point representation. We provide quantitative evidence that Ryū Printf is between 3.8 and 55 times faster than existing printf implementations.
    Furthermore, we show that both Ryū and Ryū Printf generalize to arbitrary number bases. This finding implies the existence of a fast algorithm to convert from base-10 to base-2, as long as the maximum precision of the input is known a priori.

    Supplementary Material

    a169-adams (a169-adams.webm)
    Presentation at OOPSLA '19

    References

    [1]
    Ulf Adams. 2018. Ry ¯ u: Fast Float-to-String Conversion. In Proceedings of the 39th ACM SIGPLAN 2018 Conference on Programming Language Design and Implementation (PLDI 2018). ACM, New York, NY, USA, 270–282.
    [3]
    Marc Andrysco, Ranjit Jhala, and Sorin Lerner. 2016. 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 ’16). ACM, New York, NY, USA, 555–567.
    [4]
    Anonymous. 2018. printf format string. https://en.wikipedia.org/wiki/Printf_format_string
    [5]
    Nikolay Petrovich Brusentsov and José Ramil Alvarez. 2011. Ternary Computers: The Setun and the Setun 70. In Perspectives on Soviet and Russian Computing, John Impagliazzo and Eduard Proydakov (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 74–80.
    [6]
    Robert G. Burger and R. Kent Dybvig. 1996. Printing Floating-point Numbers Quickly and Accurately. In Proceedings of the ACM SIGPLAN 1996 Conference on Programming Language Design and Implementation (PLDI ’96). ACM, New York, NY, USA, 108–116.
    [7]
    Jerome Toby Coonen. 1980. An Implementation Guide to a Proposed Standard for Floating Point Arithmetic. Computer 13, 1 (Jan. 1980), 68–79.
    [8]
    Jerome Toby Coonen. 1981. Errata: An Implementation Guide to a Proposed Standard for Floating Point Arithmetic. Computer 14, 3 (March 1981), 62.
    [9]
    Free Software Foundation, Inc. 2018. GNU libc Printf Documentation. https://www.gnu.org/software/libc/manual/html_ node/Floating_002dPoint- Conversions.html
    [10]
    David M. Gay. 1990. Correctly Rounded Binary-Decimal and Decimal-Binary Conversions. Technical Report. AT&T Bell Laboratories. Numerical Analysis Manuscript 90-10.
    [11]
    IBM. 2018. IBM Printf Documentation. https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_72/rtref/printf.htm
    [12]
    IEEE Computer Society. Microprocessor Standards Committee and Institute of Electrical and Electronics Engineers and IEEE-SA Standards Board. 2008. 754-2008 - IEEE Standard for Floating-Point Arithmetic. Institute of Electrical and Electronics Engineers (IEEE), New York.
    [13]
    Aubrey Jaffer. 2013. Easy Accurate Reading and Writing of Floating-Point Numbers. (October 2013). https://arxiv.org/abs/ 1310.8121v6 Updated January 2015.
    [14]
    Donald Ervin Knuth. 1997. The Art of Computer Programming (3rd ed.). Vol. II: Seminumerical Algorithms. Addison-Wesley, Boston, Massachusetts, United States, Chapter 4.4 Radix Conversion, p. 326.
    [15]
    Florian Loitsch. 2010. 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.
    [16]
    Microsoft. 2016. Microsoft Visual Studio 2017: Format specification syntax: printf and wprintf functions. https://docs.microsoft. com/en- us/cpp/c- runtime- library/format- specification- syntax- printf- and- wprintf- functions?view=vs- 2017
    [17]
    Klaus Samelson and Friedrich L. Bauer. 1953. Optimale Rechengenauigkeit bei Rechenanlagen mit gleitendem Komma. Zeitschrift für angewandte Mathematik und Physik (ZAMP) 4, 4 (Jul 1953), 312–316.
    [18]
    Guy L. Steele, Jr. and Jon L. White. 1990. How to Print Floating-point Numbers Accurately. In Proceedings of the ACM SIGPLAN 1990 Conference on Programming Language Design and Implementation (PLDI ’90). ACM, New York, NY, USA, 112–126.

    Cited By

    View all
    • (2023)libcdict: fast dictionaries in CJournal of Open Source Software10.21105/joss.047568:92(4756)Online publication date: Dec-2023
    • (2023)Fast number parsing without fallbackSoftware: Practice and Experience10.1002/spe.319853:7(1467-1471)Online publication date: 4-Mar-2023
    • (2021)Number parsing at a gigabyte per secondSoftware: Practice and Experience10.1002/spe.298451:8(1700-1727)Online publication date: 11-May-2021

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image Proceedings of the ACM on Programming Languages
    Proceedings of the ACM on Programming Languages  Volume 3, Issue OOPSLA
    October 2019
    2077 pages
    EISSN:2475-1421
    DOI:10.1145/3366395
    Issue’s Table of Contents
    This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs International 4.0 License.

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 10 October 2019
    Published in PACMPL Volume 3, Issue OOPSLA

    Permissions

    Request permissions for this article.

    Check for updates

    Badges

    Author Tags

    1. float
    2. performance
    3. printf
    4. string

    Qualifiers

    • Research-article

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)504
    • Downloads (Last 6 weeks)47
    Reflects downloads up to 10 Aug 2024

    Other Metrics

    Citations

    Cited By

    View all
    • (2023)libcdict: fast dictionaries in CJournal of Open Source Software10.21105/joss.047568:92(4756)Online publication date: Dec-2023
    • (2023)Fast number parsing without fallbackSoftware: Practice and Experience10.1002/spe.319853:7(1467-1471)Online publication date: 4-Mar-2023
    • (2021)Number parsing at a gigabyte per secondSoftware: Practice and Experience10.1002/spe.298451:8(1700-1727)Online publication date: 11-May-2021

    View Options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Get Access

    Login options

    Full Access

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media