(36 lines)
4 // This file defines a function to convert floating point numbers to strings.5 // For license, see: fpconv_license.txt7 /* Fast and accurate double to string conversion based on Florian Loitsch's8 * 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.15 *16 * Output:17 * The number of written characters.18 *19 * Exemplary usage:20 *21 * void print(double d)22 * {23 * char buf[24 + 1] // plus null terminator24 * int str_len = fpconv_dtoa(d, buf);25 *26 * buf[str_len] = '\0';27 * puts(buf);28 * }29 *30 */34 #endif36 /* [1] http://florian.loitsch.com/publications/dtoa-pldi2010.pdf */