Hi Alessandro, Boris Kolpackov wrote: > Serialization of floating point numbers to decimal form is actually > a very tricky issue once you need to support a round trip (e.g., > text->double->text->double) without loss of information. It took us > a long time to figure out various nuances. If you are interested, > you can take a look at how we do it in CodeSynthesis XSD (see the link > in the signature below). Also the following paper is quite useful in > understanding of the issue involved: > > http://www2.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1822.pdf
here is another link: http://www.netlib.org/fp/ Look for dtoa.c and the frontend g_fmt.c. Having the code you simply do extern "C" char * g_fmt(char*,double); ... char dblstr[32]; // 32 bytes are sufficient g_fmt(dblstr,3.14) the code is fast and mature and works fine on different hardware. There's also a paper explaining the (impressively complicated) theoretical background. Cheers, Michael --
