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 is done using a fast and simple (but not accurate!) approach and fallback to strtod if conversion can't be done the simplified way.
The code is far from being perfect so any help to improve speed, accuratie, code quality etc... is welcome.
To download the latest source do this:
git clone https://github.com/mrabine/dconv.git
To configure dconv do this:
cd dconv
mkdir build && cd build
cmake ..
To install dconv do this:
make && sudo make install
Note that building and installing the library is not required as it is a header only library.
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);