Skip to content
Prev 69264 / 398526 Next

FAQ 7.31

On May 6, 2005, at 09:00 am, Prof Brian Ripley wrote:

            
[snip]
Yes, this makes a lot of sense, and will likely prevent me from 
flogging a dead horse by executing
dozens of pointless iterations in pursuit of the dregs of those last 
few binary digits at the tail end of
some float (not to mention infinite loops).

I would have thought that if x, y are scalars then identical(x,y) would 
be the same as
all.equal(x,y,tol=.Machine$double.eps).

And it is, most of the time.

But this caught me out just now:

R>  x <- 5352970674736366
R>  identical(x,x+1)
[1] FALSE

R> all.equal(x,x+1,tol=.Machine$double.eps)
[1] TRUE


Thus  x and x+1  are not identical but nevertheless agree to within my 
machine precision, and
evidently my understanding of "machine precision" doesn't tally with 
Rreality.

Any comments?
--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743