Skip to content

joinframework/dconv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dconv

Test Status Security Status Codacy Badge Codacy Badge codecov Coverage Status Doxygen GitHub Releases GitHub License

dconv is a C++14 library for printing and parsing floating point numbers.

Double to string conversion is done using the Grisu2 algorithm, described by Florian Loitsch in its publication Printing Floating-Point Numbers Quickly and Accurately with Integers.

String to double conversion uses a fast-path implementation based on the Eisel-Lemire algorithm, with automatic fallback to strtod when inputs exceed the range or precision safely handled by the fast algorithm.

The code is far from being perfect so any help to improve speed, accuratie, code quality etc... is welcome.

Dependencies

To install dconv dependencies do this:

sudo apt update && sudo apt install libgtest-dev libgmock-dev

Download

To download the latest source do this:

git clone https://github.com/mrabine/dconv.git

Configuration

To configure dconv do this:

cmake -B build -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DDCONV_ENABLE_TESTS=ON -DDCONV_ENABLE_COVERAGE=ON

Build

To build dconv do this:

cmake --build build --config Debug

Usage

The printing API can be used this way:

#include <dconv/dtoa.hpp>

char value [25];
char* end = dconv::dtoa (value, -2.22507e-308);

The parsing API can be used this way:

#include <dconv/atod.hpp>

double value;
char* end = dconv::atod ("-2.22507e-308", value);

License

MIT

Packages

No packages published