This comment is orthogonal to most of the others. It seems that folk often want to test for equality of "real" numbers. One important one is for convergence tests. When writing my Compact Numerical Methods book I had to avoid lots of logical tests, but wanted to compare two REALs. I found that the following approach, possibly considered a trick, is to use an offset and compare
xnew + offset to xold + offset This works on the examples given to motivate the current thread with an offset of 10, for example. Motivation: Small xold, xnew compare offset with itself. Large xold and xnew are compared bitwise. Essentially we change from using a tolerance to using 1/tolerance. Perfect? No. But usable? Yes. And I believe worth keeping in mind for those annoying occasions where one needs to do a comparison but wants to get round the issue of knowing the machine precision etc. JN ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.