[R] Integer precision etc.
Douglas Bates
bates at stat.wisc.edu
Wed Aug 13 16:20:30 CEST 2003
(Ted Harding) <Ted.Harding at nessie.mcc.ac.uk> writes:
> 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
Those "integer" values are being silently converted to double
precision so what you are determining is the relative machine
precision for doubles. Use .Machine$integer.max instead. On your
platform it will probably be 2^31-1
> .Machine$integer.max
[1] 2147483647
> log(.Machine$integer.max, 2)
[1] 31
> 2^31-1
[1] 2147483647
> log(.Machine$double.eps, 2)
[1] -52
> log(.Machine$double.neg.eps, 2)
[1] -53
More information about the R-help
mailing list