From h.wickham at gmail.com  Wed May 23 11:57:22 2007
From: h.wickham at gmail.com (hadley wickham)
Date: Wed, 23 May 2007 11:57:22 +0200
Subject: [Rd] R 2.5.0 refuses to print enough digits to recover exact
	floating point values
In-Reply-To: <f8e6ff050705230251t1170b47enea9ced70a6ca4a1e@mail.gmail.com>
References: <eb97335b0705220013m6f3e137cp147d429c46717e24@mail.gmail.com>
	<4652C19F.1040509@statistik.uni-dortmund.de>
	<f8e6ff050705230251t1170b47enea9ced70a6ca4a1e@mail.gmail.com>
Message-ID: <f8e6ff050705230257q72f3dbd5ua18072424b38386@mail.gmail.com>

On 5/23/07, hadley wickham <h.wickham at gmail.com> wrote:
> On 5/22/07, Uwe Ligges <ligges at statistik.uni-dortmund.de> wrote:
> >
> >
> > Zack Weinberg wrote:
> > > 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.
> >
> > Example:
> >
> > formatC(exp(1), digits=100, width=-1)
>
> formatC(exp(1), digits=1000000, width=-1)
>  *** caught bus error ***
> address 0x2, cause 'non-existent physical address'
>
> R version 2.5.0 (2007-04-23)
> i386-apple-darwin8.9.1

Ooops, and the traceback:

Traceback:
 1: .C("str_signif", x = x, n = n, mode = as.character(mode), width =
as.integer(width),     digits = as.integer(digits), format =
as.character(format),     flag = as.character(flag), result =
blank.chars(i.strlen),     PACKAGE = "base")
 2: formatC(exp(1), digits = 1e+06, width = -1)

Hadley



[Rd] R 2.5.0 refuses to print enough digits to recover exact floating point values
hadley wickham