[R] floating point question

Bob Gray gray at jimmy.harvard.edu
Fri Jan 31 20:15:03 CET 2003


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




More information about the R-help mailing list