package dtoa

Build not checked
  1. Overview
  2. Docs
Converts OCaml floats into strings (doubles to ascii, "d to a"), using the efficient Grisu3 algorithm.

Install

dune-project
 Dependency

Authors

Maintainers

Sources

dtoa-0.3.1.tbz
sha256=d65e91d1ca794c0c82b29c8bd1d36a7507a09695b64be8c17c068b7f80d4fe67
md5=c782646b12a03015dcecf687ea120a05

Description

This is a (partial) port of Google's double-conversion library from C++ to C.

Added to opam-repository:

README

ocaml-dtoa

This library provides a function that converts OCaml floats into strings, using the efficient Grisu3 algorithm.

The Grisu3 algorithm is described in "Printing Floating-Point Numbers Quickly And Accurately with Integers" by Florian Loitsch.

The implementation is adapted from double-conversion.

Current Status

Currently, this library exposes three functions:

  • ecma_string_of_float : float -> string: formats the float according to the ECMAScript specification's implementation of Number.prototype.toString. Notably, the output of this function is valid JSON.
  • shortest_string_of_float : float -> string: formats the float as compactly as possible, for example returning 123e6 instead of 123000000 or 1.23e+08.
  • g_fmt : float -> string: formats the float in the same way as David M. Gay's g_fmt.

The underlying fast_dtoa() function computes the significand and exponent, which are formatted by the above functions in dtoa_stubs.c. It is a port of the double-conversion library from C++ to C.

Many features of double-conversion are still missing. Patches are welcome!

License

ocaml-dtoa is MIT-licensed.

Author

ocaml-dtoa was created by Facebook for the Flow project.

Dependencies (2)

  1. jbuilder >= "1.0+beta7"
  2. ocaml >= "4.01.0"

Dev Dependencies (1)

  1. ounit with-test & >= "2.0.0"

Optional Dependencies

None

Used by

None

Conflicts

None

Build status

Results of building dtoa with each compiler on check.ci.ocaml.org, run of against opam-repository 7cdc698. All results for this package.

Each result links to its build log. To keep crawlers from overloading the site, build logs require a GitHub sign-in (see ocurrent/opam-health-check). On your first log, GitHub asks you to “Authorize opam-health-check”, the OCurrent app that runs these checks; it sees only your public profile, not your repositories. The sign-in lasts 30 days.

This version is not in the latest run; the versions below are.

Version OCaml 4.11 OCaml 4.14 OCaml 5.2 OCaml 5.4 OCaml 5.5
0.3.3 good good good good good
  • good Package successfully built
  • partial One of the dependencies failed to build
  • bad Package failed to build
  • n/a Package is not available in this environment
  • internal Internal failure