From zack at cogsci.ucsd.edu  Tue May 22 09:13:38 2007
From: zack at cogsci.ucsd.edu (Zack Weinberg)
Date: Tue, 22 May 2007 00:13:38 -0700
Subject: [Rd] R 2.5.0 refuses to print enough digits to recover exact
	floating point values
Message-ID: <eb97335b0705220013m6f3e137cp147d429c46717e24@mail.gmail.com>

I have noticed that in R 2.5.0, no method of textual output will print
a "double" mode quantity with more than 15 digits after the decimal
point.  From the help page (?print.default) it appears that this is
intentional, since digits after the fifteenth may be uncertain.
However, fifteen digits after the decimal point are not enough to
represent all the values that an IEEE-double can take.  (You need one
more.)  This means it is now impossible to write out data in textual
format (e.g. in order to manipulate it with another program) and read
back in exactly the same values.  Some analyses are sensitive to this
sort of extra rounding, especially if it happens repeatedly.

I'd really appreciate some way of forcing R to print enough digits to
represent every possible IEEE double value.  I would also argue that
this should be the default behavior of dump(), write.table() and
friends, and save(...,ascii=TRUE), to prevent data loss.

[Tangentially, support for C99 hexadecimal notation for floating point
values in input and output would also be nice, but wouldn't help much
for interoperability, since very few programs understand it.]

zw



[Rd] R 2.5.0 refuses to print enough digits to recover exact floating point values
Zack Weinberg