[R] floating point question
Prof Brian D Ripley
ripley at stats.ox.ac.uk
Fri Jan 31 20:44:05 CET 2003
It's a difference in the `libc'. Asking for more precision than the
arithmetic has is asking for fairly random results. The differences are as
likely to be in the *printing* as in the computations.
On Fri, 31 Jan 2003, Bob Gray wrote:
> Does anyone know precisely what is different about the arithmetic
> and/or storage of double precision floating point to produce the
> following differences between the Sun and Windows versions (Splus 6
> on the same Windows 2000 machine gives the same results as Solaris)?
>
> R 1.6.1, Sun Solaris, gcc + an old Sun f77
> > options(digits=20)
> > 1+(1/2^53+1/2^106)
> [1] 1
> > 1+(1/2^53+1/2^105)
> [1] 1.0000000000000002
> > 1+(1/2^53+1/2^64)
> [1] 1.0000000000000002
> > 1+(1/2^53+1/2^63)
> [1] 1.0000000000000002
>
> R 1.6.1, Windows 2000, binary downloaded from CRAN
> > options(digits=20)
> > 1+(1/2^53+1/2^106)
> [1] 1
> > 1+(1/2^53+1/2^105)
> [1] 1
> > 1+(1/2^53+1/2^64)
> [1] 1
> > 1+(1/2^53+1/2^63)
> [1] 1.0000000000000002
>
> (This may be frivolous, but I have been using the first 2 lines as an
> example in a course.)
>
> Thanks
> --
> Bob Gray
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> http://www.stat.math.ethz.ch/mailman/listinfo/r-help
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list