CBFalconer said:
jameskuyper wrote:
... snip ...
Such a conversion cannot fail, since the input is an integer, and
no information is lost. Assuming the integral capacity of the
floating point is as large as the integer.
Yes - it would be nice if the standard had contained some words actually
making such a guarantee. What is has, instead, is 5.2.4.2.2p5, which says:
"The accuracy of the floating-point operations (+, -, *, /) and of the
library functions in <math.h> and <complex.h> that return floating-point
results is implementation defined, as is the accuracy of the conversion
between floating-point internal representations and string
representations performed by the library functions in <stdio.h>,
<stdlib.h>, and <wchar.h>. The implementation may state that the
accuracy is unknown."
You get better results if you restrict your comments to implementations
which predefine __STDC_IEC_559__; such implementations are required to
conform to IEEE/IEC 559, which imposes fairly strict accuracy
requirements on all floating point operations.