“Every time numbers are transferred from external decimal to internal binary or vice-versa, precision can be lost.”
Can you reassure me that 9 digits is definitely enough?
That assertion is true IF you are trying to represent any number on the number line using a floating point representation. For example, the value 0.1 (one tenth) in binary is an infinite series of digits of the form 0.1001100110011001… Obviously this has to be truncated into 24 bits for fit into a single precision float, and this is the “loss of precision” he talked about.
Our problem is a different one. We are trying to reconstruct a value that has already been converted into the nearest representable floating-point value, then converted to ascii. There is no loss of precision for reconstructing values that were previously floats, only for trying to re-represent arbitrary values on the number line.
FYI, here’s a paper on how it’s done. “Printing Floating-Point Numbers Quickly and Accurately” here
http://www.cs.indiana.edu/~burger/FP-Printing-PLDI96.pdf or http://citeseer.nj.nec.com/28233.html
[Admin: added alternative link]