Theorem 15

When a binary IEEE single precision number is converted to the closest eight digit decimal number, it is not always possible to uniquely recover the binary number from the decimal one. However, if nine decimal digits are used, then converting the decimal number to the closest binary number will recover the original floating-point number.

Proof

Binary single precision numbers lying in the half open interval have 10 bits to the left of the binary point, and 14 bits to the right of the binary point. Thus there are different binary numbers in that interval. If decimal numbers are represented with 8 digits, then there are decimal numbers in the same interval. There is no possible bijection from a set of decimal numbers to a set of binary numbers, so 8 decimal digits is not enough to uniquely represent each single precision binary number.

To show that 9 digits are sufficient, it is sufficient to show that the spacing between binary numbers is always greater than the spacing between decimal numbers. This will ensure that for each decimal number , the interval contains at most one binary number. Thus each binary number rounds to a unique decimal number which in turn rounds to a unique binary number.

To show that the spacing between binary numbers is always greater than the spacing between decimal numbers, consider an interval . On this interval, the spacing between consecutive decimal numbers is . On , where is the smallest integer such that , the spacing of binary numbers is , and the spacing continuously increases along the interval. Thus, it is enough to check that . But in fact, since , then

The same argument applied to double precision shows that 17 decimal digits are required to recover a double precision number.

Was this page helpful?