Different algorithms for converting binary to decimal floating-point numbers

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • Drachennest

    Different algorithms for converting binary to decimal floating-point numbers

  • jfreesvg

    A fast, lightweight Java library for creating Scalable Vector Graphics (SVG) output.

  • In Java, many number-to-string implementations use NumberFormat. This is abysmally slow if the problem domain doesn't require internationalization, which is the case for machine-readable file formats, such as SVG. When I performance tested JMathTeX for rendering TeX, the bottleneck for converting TeX into SVG elements was JFreeSVG's use of NumberFormat[0]. Replacing NumberFormat with RyuDouble doubled the throughput[1]. (Reusing a StringBuilder for to concatenate strings yielded another doubling.)

    For KeenType[2], a fork of the New Typesetting System (and more complete TeX implementation than JMathTeX), I added an SVG generator that converts numbers to string using a StackOverflow answer[3], instead of using Ryu[4]. The performance was even better and the algorithm vastly simpler.

    Knuth was right: measure, then optimize.

    [0]: https://github.com/jfree/jfreesvg

    [1]: https://github.com/jfree/jfreesvg/pull/30

    [2]: https://github.com/DaveJarvis/KeenType

    [3]: https://stackoverflow.com/a/10554128/59087

    [4]: https://github.com/DaveJarvis/KeenType/blob/fef005579021f394...

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • KeenType

    Discontinued Pure Java typesetting system

  • In Java, many number-to-string implementations use NumberFormat. This is abysmally slow if the problem domain doesn't require internationalization, which is the case for machine-readable file formats, such as SVG. When I performance tested JMathTeX for rendering TeX, the bottleneck for converting TeX into SVG elements was JFreeSVG's use of NumberFormat[0]. Replacing NumberFormat with RyuDouble doubled the throughput[1]. (Reusing a StringBuilder for to concatenate strings yielded another doubling.)

    For KeenType[2], a fork of the New Typesetting System (and more complete TeX implementation than JMathTeX), I added an SVG generator that converts numbers to string using a StackOverflow answer[3], instead of using Ryu[4]. The performance was even better and the algorithm vastly simpler.

    Knuth was right: measure, then optimize.

    [0]: https://github.com/jfree/jfreesvg

    [1]: https://github.com/jfree/jfreesvg/pull/30

    [2]: https://github.com/DaveJarvis/KeenType

    [3]: https://stackoverflow.com/a/10554128/59087

    [4]: https://github.com/DaveJarvis/KeenType/blob/fef005579021f394...

  • llvm-project

    The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.

  • LLVM libc's decimal float conversion is based on Ulf Adams' Ryu Printf algorithm (one of the algorithms mentioned in the article). If you're interested in this area, you can look at the code, https://github.com/llvm/llvm-project/blob/main/libc/src/__su... and patches are always welcome :-)

    Initial commit, https://reviews.llvm.org/D131023

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts