Re: [Rd] R 2.5.0 refuses to print enough digits to recover exact floating point values

From: Zack Weinberg <zack_at_cogsci.ucsd.edu>
Date: Sat, 26 May 2007 17:50:43 -0700

On 5/23/07, Prof Brian Ripley <ripley_at_stats.ox.ac.uk> wrote: [...]
> It really is the case that writing out a number to > 15 significant digits
> and reading it back in again is not required to give exactly the same
> IEC60559 (sic) number, and furthermore there are R platforms for which
> this does not happen. What Mr Weinberg claimed is 'now impossible' never
> was possible in general (and he seems to be berating the R developers for
> not striving to do better than the C standard requires of OSes). In fact,
> I believe this to be impossible unless you have access to extended
> precsion arithmetic, as otherwise printf/scanf have to use the same
> arithmetic as the computations.

I did not intend to berate anyone - I may have come across that way because I was frustrated, in which case I apologize.

 I *do* think it is reasonable to expect a numerical analysis program to have numerically stable, 100% accurate, perfectly roundtripping floating-point-to-text conversion, even if the system's runtime libraries don't get it right, even if the hardware does not provide extended precision to make it easier. In the worst case you have to muck around with software-emulated extended-precision FP, and even that really isn't that hard.

There is code in GCC that does exactly this, it's only about 5000 LOC, and it does quite a bit more than R would need. If there were interest I could see about porting it across.

zw



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Mon 28 May 2007 - 09:09:00 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 28 May 2007 - 09:34:17 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.