Settings

Theme

Compact and fast double-to-string conversion

4 points by erthink 6 years ago · 0 comments · 1 min read


Ryu algorithm by Ulf Adams (https://github.com/ulfjack/ryu) known to fastest in much cases, especially for short string representations. However, I would like to draw attention to my own speed-competing but more compact GRISU-based implementation.

Briefly, about this implementation:

1. it is a GRUSU-based, but not exactly the GRISU2;

2. for now produces only a raw ASCII representation, e.g. -22250738585072014e-324 without dot and '\0' at the end;

3. compared to Ryu, it significantly less code size and spends less clock cycles per digit, but is slightly inferior in a whole because generates a longer ASCII representation.

Now I would like to get feedback, assess how much this is in demand and collect suggestions for further improvements. For instance, I think that it is reasonable to implement conversion with a specified precision (i.e., with a specified number of digits), but not provide a printf-like interface.

The benchmark source code: https://github.com/leo-yuriev/dtoa-benchmark

The d2a() implementation: https://github.com/leo-yuriev/erthink/blob/master/erthink_d2a.h The test source code: https://github.com/leo-yuriev/erthink/blob/master/test/d2a.cxx

Any suggestions are welcome!

No comments yet.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection