4 ms·
That's basically how Gay's dtoa works, and you'll find it copied into many projects—Python, for example, uses it for repr(). http://www.netlib.org/fp/dtoa.c ht
by dietrichepp 10y ago
That's basically how Gay's dtoa works, and you'll find it copied into many projects—Python, for example, uses it for repr().
http://www.netlib.org/fp/dtoa.c http://www.netlib.org/fp/dtoa.c
- Avernar 10y agoI've long ago stopped using C's standard library floating point routines and use Gay's code. Main reason was inconsistencies between compilers.
- floitsch 10y agoThere is also http://github.com/double-conversion http://github.com/double-conversion (of which I'm the author). It's based on http://florian.loitsch.com/publications/dtoa-pldi2010.pdf http://florian.loitsch.com/publications/dtoa-pldi2010.pdf I'm obviously biased, but I think the API is easier, and the algorithm is faster. However, it's in C++ (which might not suit your needs), and it requires more code (especially with the precomputed constants).