code / tomo

Lines41.3K C23.7K Markdown9.7K YAML5.0K Tomo2.3K
7 others 763
Python231 Shell230 make212 INI47 Text21 SVG16 Lua6
(36 lines)
1 #ifndef FPCONV_H
2 #define FPCONV_H
4 // This file defines a function to convert floating point numbers to strings.
5 // For license, see: fpconv_license.txt
7 /* Fast and accurate double to string conversion based on Florian Loitsch's
8 * Grisu-algorithm[1].
9 *
10 * Input:
11 * fp -> the double to convert, dest -> destination buffer.
12 * The generated string will never be longer than 24 characters.
13 * Make sure to pass a pointer to at least 24 bytes of memory.
14 * The emitted string will not be null terminated.
16 * Output:
17 * The number of written characters.
19 * Exemplary usage:
21 * void print(double d)
22 * {
23 * char buf[24 + 1] // plus null terminator
24 * int str_len = fpconv_dtoa(d, buf);
26 * buf[str_len] = '\0';
27 * puts(buf);
28 * }
30 */
32 int fpconv_dtoa(double fp, char dest[24]);
34 #endif
36 /* [1] http://florian.loitsch.com/publications/dtoa-pldi2010.pdf */