[R] Integer precision etc.

Thomas Lumley tlumley at u.washington.edu
Wed Aug 13 16:09:50 CEST 2003


On Wed, 13 Aug 2003 Ted.Harding at nessie.mcc.ac.uk wrote:

> Hi Folks,
> With a bit of experimentation I have determined (I think)
> that on my R implementation the largest positive integer
> that is exactly represented is (2^53 - 1), based on
>
> > (((2^53)-1)+1) - ((2^53)-1)
> [1] 1
> > ((2^53)+1) - (2^53)
> [1] 0
>

The variable .Machine contains this sort of thing.

The largest exactly represented integer is
   .Machine$integer.max
and the largest integer exactly represented as a double will be
 2^.Machine$double.digits-1

I believe the floating point formats are the same on all versions of R at
the moment (though the integer formats might not be)

	-thomas




More information about the R-help mailing list