best way to output a full precision double into a text file
Posted
by
flevine100
on Stack Overflow
See other posts from Stack Overflow
or by flevine100
Published on 2011-01-10T04:17:31Z
Indexed on
2011/01/10
4:53 UTC
Read the original article
Hit count: 243
Hi, I need to use an existing text file to store some very precise values. When read back in, the numbers essentially need to be exactly equivalent to the ones that were originally written. Now, a normal person would use a binary file... for a number of reasons, that's not possible in this case.
So... do any of you have a good way of encoding a double as a string of characters (aside from increasing the precision). My first thought was to cast the double to a char[] and write out the chars. I don't think that's going to work because some of the characters are not visible, produce sounds, and even terminate strings ('\0'... I'm talkin to you!)
Thoughts?
© Stack Overflow or respective owner