Skip to content
Prev 55770 / 63424 Next

compairing doubles

> Hello, Watch out for operator precedence.

indeed!  (but not only)
I would still quite strongly recommend against such a
definition:

If you ask for  help(all.equal)
you do see that it is a generic with a   all.equal.numeric()
method which has several extra arguments 
(new ones even in R-devel)  the most important one being the
numerical  'tolerance'  with a default of
sqrt(.Machine$double.eps)  { == 2^-26 == 1.490116e-08  on all current platforms}

Of course there is some arbitraryness in that choice
{{ but only *some*: the default is related to finding the minimum of
   smooth function which hence is locally quadratic at a "decent"
   minimum hence sqrt(.)
}}
but I find it important sometimes to increase the equality
strictness of that tolerance.

Hiding everything behind a new operator which does not allow to
take into account that there are quite a few versions of
near-equality --- only partly) mirrored by the existence of
extra arguments of all.equal() --- only encourages simplified
thinking about the underlying subtle issues  which already too
many people don't care to know about.

(( e.g. all those people only caring for speed, but not for
   accuracy and reliability ... ))

Martin Maechler
ETH Zurich and R Core