Giter Site home page Giter Site logo

watch-later / drachennest Goto Github PK

View Code? Open in Web Editor NEW

This project forked from abolz/drachennest

0.0 0.0 0.0 5.37 MB

Different algorithms for converting binary to decimal floating-point numbers

License: Boost Software License 1.0

C++ 90.15% C 5.69% Python 3.94% CMake 0.22%

drachennest's Introduction

Build Status Build status codecov

Converting binary floating-point to decimal floating-point numbers.


Grisu / Dragon

Contains an implementation of the Grisu2 and Grisu3 algorithms as described in

The Grisu3 implementation uses the Dragon4 algorithm as a fallback.

Ryu

Contains an implementation of the Ryu algorithm as described in

The implemenation also contains a (fast!) strtod implementation, which can be used to convert decimal numbers with at most 17 significant decimal digits back into binary floating-point numbers. (Note that none of the algorithms here will ever produce more than 17 significant digits.)

Schubfach

Contains an implementation of the Schubfach algorithm as described in

The name of this algorithm "deliberately departs from a long lineage of fabulous drakes".

Dragonbox

Contains a slightly modified version the reference implementation of Junekey Jeon's Dragonbox algorithm.


Grisu3, Ryu, Schubfach, and Dragonbox are optimal, i.e. the output string

  1. rounds back to the input number when read in,
  2. is as short as possible,
  3. is as close to the input number as possible.

These algorithms (currently) assume that the input rounding algorithm uses round-to-nearest-even to break ties. Grisu2 only is optimal for ~99% of all floating point numbers, though it guarantees the first property for all of its inputs, regardless of how the input rounding mode breaks ties.


Benchmarks

Benchmarks were run on an Intel Core i7-9750H, using Visual Studio 2019 16.7.7, Clang 10.0, 64-bit.

Timings are in ns.


For this benchmark uniformly distributed random doubles in the range [1,2] have been generated. These numbers were then rounded to N significant digits and converted to decimal using the given algorithm.

BenchDigits


Uniformly distributed random numbers in the range [10^i, 10^(i+1)] for i=-12,...,12.

BenchUniform


Uniformly distributed random numbers in the range [0, 10^10]. Each benchmark is run 10 times (using different numbers each run).

BenchUniformE10


Random bit patterns. Each benchmark is run 10 times (using different numbers each run).

BenchRandom

drachennest's People

Contributors

abolz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.